跳轉到內容

LaTeX/目錄和圖列表

來自華夏公益教科書,開放的書籍,開放的世界

基本概念和通用命令

[編輯 | 編輯原始碼]

基本 LaTeX 提供了根據標題或題注自動生成目錄 (ToC, \tableofcontents) 和表/圖列表 (LoT, \listoftables/LoF, \listoffigures) 的方法。 要排版目錄 (或 LoT/LoF),LaTeX 需要輔助檔案;這意味著每次 ToC 更新至少需要兩次 LaTeX 執行。

\documentclass{article}
\usepackage{blindtext}
\begin{document}
\tableofcontents
\listoffigures
\section{Wombat}
\blindtext
\section{Alpaca}
\blindtext
\begin{figure}
\caption{This is a caption for a non-existing image}
\end{figure}
\section*{Not in ToC}
\end{document}

The default appearance of table of contents and list of figures with the article class


對於文章類,這些列表在內部是無編號的節。對於標準報告和書籍類,它們是無編號的章;每個都從新頁開始。

預設情況下,無編號的章和節不會出現在目錄中。 如何使它們顯示

目錄有深度。預設情況下,目錄中存在三個分節級別。 你可以指定 到哪個級別 ToC 應該顯示詳細資訊。 \setcounter{tocdepth}{<number>}

文件和列表的不同標題

[編輯 | 編輯原始碼]

分節命令以及 \caption 提供一個可選引數,可以接受不同的標題。 通常,這是用於為 ToC 或 LoF/LoT 提供較短的題注。

\documentclass{article}
\usepackage{blindtext}
\begin{document}
\tableofcontents
\listoffigures
\section[Alpaca]{Wombat}
\blindtext
\begin{figure}
	\caption[This is the LoF entry]{This is a caption for a non-existing image}
\end{figure}
\end{document}
LoF 和 ToC 中的替代標題

每章的目錄

[編輯 | 編輯原始碼]

etoc 包可以讓你獲得單個章節的目錄。 以下是一個小例子。

單個章節的本地目錄


\documentclass{book}
\usepackage{etoc}
\usepackage{blindtext}
\begin{document}
\tableofcontents
\etocsettocstyle{\subsection*{This Chapter contains:}}{\noindent\rule{\linewidth}{.4pt}}
\chapter{Extinct Species}
\localtableofcontents
\section{Mammals}
\subsection{Big-eared hopping mouse}
\subsection{Jamaican rice rat}
\subsection{White-footed rabbit-rat}
\section{Butterflies}
\subsection{Nymphalidae}
\subsection{Lycaenidae}
\subsection{Uraniidae}
\end{document}


自定義目錄

[編輯 | 編輯原始碼]

如果你想自定義你的目錄,你可以從標準類的一些包中選擇。 然而,memoirKOMA-script 具有內建的自定義方法,使用包會破壞這些類的功能。

常見問題

[編輯 | 編輯原始碼]

數字與標題重疊

[編輯 | 編輯原始碼]

LaTeX 為目錄中的條目使用定義的空間,這意味著長的章節或節號有時會與標題重疊。 一個簡單的解決方案是透過在序言中新增 \renewcommand{\numberline}[1]{#1~} 來覆蓋它。 不過,使用專門用於 ToC 自定義的包可能更好。

章節號與章節標題重疊,這是一個常見問題。
華夏公益教科書