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

歡迎訪問 生活随笔!

生活随笔

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

编程问答

设置目录_[LaTeX 尝试] titletoc - 为算法目录、定理目录等设置子目录

發布時間:2024/7/19 编程问答 44 豆豆
生活随笔 收集整理的這篇文章主要介紹了 设置目录_[LaTeX 尝试] titletoc - 为算法目录、定理目录等设置子目录 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

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

titletoc 宏包提供了定制目錄列表樣式的功能,本文主要討論其中的「創建子目錄」功能。

標準目錄的子目錄

LaTeX 的典型目錄通過 tableofcontents 輸出,一個文檔里最多使用一次。在實踐中,長文檔有包含多個「目錄」的需求:

  • 精簡目錄,常出現在完整目錄之前。精簡目錄只包含一到兩級章節標題,篇幅短,完整目錄包含更多章節層次。
  • 子目錄,常出現在各章開頭,僅包含當前章下的次級標題。例如
Chapter 2 Title <start of partial toc> 2.1 Section title ....... page 10 2.1.1 Subsection title .... page 11 2.1.2 Subsection title .... page 12 2.2 Section title ....... page 15 ... ... <end of partial toc><start of chapter contents> ... ...

titletoc 提供了生成子目錄的命令 startcontents 和 printcontents:

documentclass{article} usepackage{lipsum} usepackage{titletoc}begin{document} % tableofcontents 仍可正常使用 %tableofcontentssection{title} startcontents printcontents{}{2}{}subsection{title} lipsum[23] subsection{title} lipsum[23]section{title} startcontents printcontents{}{2}{}subsection{title} lipsum[23] subsection{title} lipsum[23] subsubsection{title} lipsum[23]end{document}

子目錄(已用藍色突出顯示)

說明:section 的目錄層級為 1,子目錄包含的目錄層級為 2 及以下,所以我們使用了 printcontents{}{2}{}。

圖表目錄的子目錄

LaTeX (的標準文檔類)還提供了圖目錄和表目錄,分別通過 listoffigures 和 listoftables 輸出。titletoc 也提供了對應的子目錄命令:startlist 和 printlist:

documentclass{article} usepackage{lipsum} usepackage{titletoc}begin{document} section{title} startlist{lof} printlist{lof}{}{}lipsumbegin{figure} content caption{title} end{figure} begin{figure} content caption{title} end{figure} begin{figure} content caption{title} end{figure}section{title} startlist{lof} printlist{lof}{}{}begin{figure} content caption{title} end{figure} begin{figure} content caption{title} end{figure}end{document}

說明:startlist{lof} 和 printlist{lof}{}{} 里的 lof 用于指定圖目錄,其中 lof 對應圖目錄的輔助文件拓展名。

其他目錄的子目錄

文檔中還會用到其他目錄,如算法目錄、定理目錄、示例目錄等。仍可使用 titletoc 為這些目錄列表輸出子目錄,但需要做一些設置。我們以 chemmacros 宏包提供的(化學)反應列表為例:

% 1. 了解新列表使用的拓展名,此處為 lor (list of reactions) % 2. 為 lor 分配一個新的子目錄拓展名,這里使用 por (partial list of reactions) defttl@partiallor{plr} % 3. 把 lor “注冊”到 titletoc 內部的、把目錄項寫入輔助文件的命令中 apptocmdttl@writepartial{ttl@topartial{lor}{#1}{#2}}{}{fail}% 上述 % - apptocmd 由 etoolbox 宏包提供 % - ttl@writepartial 在 titletoc.sty 中的定義為 defttl@writepartial#1#2{%ttl@topartial{toc}{#1}{#2}%ttl@topartial{lof}{#1}{#2}%ttl@topartial{lot}{#1}{#2}%ttl@writefile{#1}{#2}}

完整例子

documentclass[openany]{book} usepackage{chemmacros} usepackage{titlesec} usepackage{titletoc}usechemmodule{reactions}makeatletter defttl@partiallor{plr}apptocmdttl@writepartial{ttl@topartial{lor}{#1}{#2}}{}{fail} makeatotherbegin{document} % you can still use listofreactions %listofreactionschapter{title} startlist{lor} printlist{lor}{}{} begin{reaction} A -> B end{reaction} begin{reaction} A -> B end{reaction} begin{reaction} A -> B end{reaction}chapter{title} startlist{lor} printlist{lor}{}{} begin{reaction} A -> B end{reaction} begin{reaction} A -> B end{reaction}end{document}

總結

以上是生活随笔為你收集整理的设置目录_[LaTeX 尝试] titletoc - 为算法目录、定理目录等设置子目录的全部內容,希望文章能夠幫你解決所遇到的問題。

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