日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

idea在目录中前添加目录_[LaTeX Beamer] 为目录项添加页码

發布時間:2025/3/15 编程问答 54 豆豆
生活随笔 收集整理的這篇文章主要介紹了 idea在目录中前添加目录_[LaTeX Beamer] 为目录项添加页码 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

本文已加入專欄文章目錄,歸入「進階使用」文章系列。

本文介紹了為 beamer 文檔類的目錄條目添加頁碼的方法,該方法可用于一般情況下的 beamer 目錄條目內容(不包含樣式的定制)修改需求。


beamer 的目錄,默認不顯示各條目的頁碼。

下面我們嘗試把頁碼加上。

先搜一搜

  • Beamer: tableofcontents with page numbers
  • Latex beamer: slide numbers for subsubsections

第二個鏈接里的改法很簡單,試一試。

makeatletter defbeamer@endinputifotherversion#1{} defbeamer@sectionintoc#1#2#3#4#5{{huge #2 hfill page #3 par}} defbeamer@subsectionintoc#1#2#3#4#5#6{{normalsize #3 hfill page #4 par}} defbeamer@subsubsectionintoc#1#2#3#4#5#6#7{{tiny #4 hfill page #5 par}} makeatother

有效果,但是很粗糙。根據第二個鏈接里的說法,信息在 toc 文件里都有。我們來看看 toc 文件,順便再看一看命令 beamer@sectionintoc 的定義。

$ cat beamer-test.toc #為了讓下方內容正確高亮,此處加一個 $ 符號,下同 beamer@sectionintoc {1}{what}{2}{0}{1} beamer@subsectionintoc {1}{1}{why}{3}{0}{1} beamer@subsubsectionintoc {1}{1}{1}{blah}{4}{0}{1} beamer@sectionintoc {2}{what2}{5}{0}{2}$ latexdef -c beamer -s beamer@sectionintoc #$ % beamerbasetoc.sty, line 108: defbeamer@sectionintoc#1#2#3#4#5{%ifnumc@tocdepth>0%ifnum#4=beamer@showpartnumber%{beamer@saveanother%gdefbeamer@todo{}%beamer@slideinframe=#1relax%expandafteronlybeamer@tocsections{gdefbeamer@todo{%beamer@tempcount=#5relax%advancebeamer@tempcount bybeamer@sectionadjust%ifnumbeamer@tempcount>0edefinserttocsectionnumber{thebeamer@tempcount}%elsedefinserttocsectionnumber{}%fi%definserttocsection{hyperlink{Navigation#3}{#2}}%beamer@tocifnothide{ifnumc@section=#1beamer@toc@cselsebeamer@toc@osfi}%{%ifbeamer@pausesectionspausefi%ifxbeamer@toc@oossbeamer@hidetextvskip1.5emelsevfillfi{%hbox{vbox{%defbeamer@breakhere{}%beamer@tocact{ifnumc@section=#1beamer@toc@cselsebeamer@toc@osfi}{section in toc}}}%par%}%}%}%}%beamer@restoreanother%}beamer@todo%fifi% }

仔細觀察,發現關鍵在 beamer@sectionintoc 定義的

definserttocsection{hyperlink{Navigation#3}{#2}}%

這一行。原始定義很長,我們用 xpatch 的功能來完成重定義

% usepackage{xpatch}makeatletter xpatchcmd{beamer@sectionintoc}{hyperlink{Navigation#3}{#2}}{hyperlink{Navigation#3}{#2hfill#3}}{}{ddt}xpatchcmd{beamer@subsectionintoc}{hyperlink{Navigation#4}{#3}}{hyperlink{Navigation#4}{#3hfill#4}}{}{ddt}xpatchcmd{beamer@subsubsectionintoc}{hyperlink{Navigation#5}{#4}}{hyperlink{Navigation#5}{#4hfill#5}}{}{ddt} makeatother

看看效果,事情就這么成了。

再回過去看第一個鏈接里的,修改 beamer@section 定義的做法,發現它的關鍵在這一處修改

longdefbeamer@section[#1]#2{% ... ... % before % addtocontents{toc}{protectbeamer@sectionintoc{thec@section}{#2}{thec@page}{thec@part}% % after addtocontents{toc}{protectbeamer@sectionintoc{thec@section}{#2hfillthec@page}{thec@page}{thec@part}% ... ... }

這樣就能理解了,第一個鏈接里的做法是,使得往 toc 文件寫入的是

beamer@sectionintoc {1}{whathfill2}{2}{0}{1}

這樣,beamer@sectionintoc 接受的第二個參數,就直接包含了需要輸出的所有內容(whathfill2)。從定制 beamer 樣式的角度,這種改法更好。同樣使用 xpatch,對應的修改是

makeatletter xpatchcmd{beamer@section}{{#2}{thec@page}}{{#2hfillthec@page}{thec@page}}{}{ddt}xpatchcmd{beamer@subsection}{{#2}{thec@page}}{{#2hfillthec@page}{thec@page}}{}{ddt}xpatchcmd{beamer@subsubsection}{{#2}{thec@page}}{{#2hfillthec@page}{thec@page}}{}{ddt} makeatother

最后附上用于生成本文配圖的 LaTeX 源碼

documentclass{beamer} usepackage{xpatch}% 重定義 % ... ...begin{document} begin{frame}tableofcontents end{frame}section{what} begin{frame} content end{frame}subsection{why} begin{frame} content end{frame}subsubsection{blah} begin{frame} content end{frame}section{what2} begin{frame} content end{frame} end{document}

總結

以上是生活随笔為你收集整理的idea在目录中前添加目录_[LaTeX Beamer] 为目录项添加页码的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。