设置目录_[LaTeX 尝试] titletoc - 为算法目录、定理目录等设置子目录
生活随笔
收集整理的這篇文章主要介紹了
设置目录_[LaTeX 尝试] titletoc - 为算法目录、定理目录等设置子目录
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
本文已加入專欄文章目錄,歸入「進階使用」文章系列。
titletoc 宏包提供了定制目錄列表樣式的功能,本文主要討論其中的「創建子目錄」功能。
標準目錄的子目錄
LaTeX 的典型目錄通過 tableofcontents 輸出,一個文檔里最多使用一次。在實踐中,長文檔有包含多個「目錄」的需求:
- 精簡目錄,常出現在完整目錄之前。精簡目錄只包含一到兩級章節標題,篇幅短,完整目錄包含更多章節層次。
- 子目錄,常出現在各章開頭,僅包含當前章下的次級標題。例如
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 - 为算法目录、定理目录等设置子目录的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: jdbc获取结果行数,如何获取JDBC中
- 下一篇: 个人计算机有控制器和运算器吗,cpu是由