LaTex目录管理

"本文详细介绍了如何在LaTeX中生成章节目录、图片目录和表格目录。通过使用`section`,`subsection`等命令定义章节结构,并使用` ableofcontents`生成目录。对于图片目录,使用`listoffigures`,并通过`caption`定义图片标题。对于表格目录,使用`listoftables`。此外,还展示了如何自定义目录名称,以及如何管理和缩短插图标题。"

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

LaTex生成章节,图片,表格目录

章节目录

在latex中,每个章节都由特定的关键字命令定义,如:“\section{},subsection{},subsubsection{}等”,利用这些关键字,我们可以生成文章的章节结构,并根据这些章节的结构和标题生成章节目录。

普通章节定义

章节定义:

\section{一级标题名}
\subsection{二级标题名}
\subsubsection{三级标题名}
...

隐藏章节定义

如果希望某一个章节拥有章节的格式,但是并不对其进行编号,也不放进章节目录中,则可以在定义章节时,在关键字和标题名之间加上’*’。

\section*{一级标题名}
\subsection*{二级标题名}
\subsubsection*{三级标题名}
...

章节目录生成

\tableofcontents

示例:

\documentclass[UTF8]{article}
\usepackage{ctex}

\begin{document}

\title{Chapter Directory}
\author{Qltan}
\maketitle

\tableofcontents
\section{Section1}
Section1 contents
\subsection{Subsection1.1}
Subsection1.1 contents
\subsubsection{Subsection1.1.1}
Subsection1.1.1 contents
\subsubsection*{Subsection1.1.2}
Subsection1.1.2 contents
\subsection{Subsection1.2}
Subsection1.2 contents

\section{Section2}
\subsection{Subsection2.1}
Subsection2.1 contents
\subsection*{Subsection2.2}
Subsection2.2 contents
\subsection{Subsection2.3}
Subsection2.3 contents

\section*{Section3}
\subsection{Subsection3.1}
Subsection3.1 contents

\end{document}

在这里插入图片描述

插图目录(索引)

在文章中插入图片后,使用“\listoffigures”可以在文章中自动生成插图索引。
示例:

\documentclass[UTF8]{article}

\begin{document}

\listoffigures

\begin{figure}[!htp]
    \centering
    \fbox{ figure 1}
    \caption{The detail in figure 1, which contains many special symbols and content details, is usually long and takes up multiple lines.}
\end{figure}
\begin{figure}[!htp]
    \centering
    \fbox{ figure 2}
    \caption{The detail in figure 2, which contains many special symbols and content details, is usually long and takes up multiple lines.}
\end{figure}
\begin{figure}[!htp]
    \centering
    \fbox{ figure 3}
    \caption{The detail in figure 3, which contains many special symbols and content details, is usually long and takes up multiple lines.}
\end{figure}
\end{document}

效果:
在这里插入图片描述
上面生成的目录还存在一些问题,比如:“目录名称不合适”,“目录中图片标题太长”。针对这两个问题,我们可以采用如下方法:

修改插图目录的名称

使用命令“\renewcommand{\listfigurename}{Figures}”来修改插图目录的名称(此命令需要放在“\begin{document}”之前!),此命令会使用“Figures”替代“List of Figures”。
示例:

\documentclass[UTF8]{article}
\renewcommand{\listfigurename}{Figures}

\begin{document}

\listoffigures

\begin{figure}[!htp]
    \centering
    \fbox{ figure 1}
    \caption{The detail in figure 1, which contains many special symbols and content details, is usually long and takes up multiple lines.}
\end{figure}
\begin{figure}[!htp]
    \centering
    \fbox{ figure 2}
    \caption{The detail in figure 2, which contains many special symbols and content details, is usually long and takes up multiple lines.}
\end{figure}
\begin{figure}[!htp]
    \centering
    \fbox{ figure 3}
    \caption{The detail in figure 3, which contains many special symbols and content details, is usually long and takes up multiple lines.}
\end{figure}
\end{document}

效果:
在这里插入图片描述

修改插图目录中的插图标题

在插入图片时,若直接使用“\caption{图片标题}”来定义图片的标题,则插图目录会默认使用此标题。而有时图片下方的标题会包含一些图片内容的细节解释,会让标题变的冗长,导致目录太长,不美观。此时,若想让目录中只包含简单的图片标题,而在图片下方的标题包含细节解释,则需要使用“\caption[图片标题]{包含图片细节的标题}”来定义图片标题。
示例:

\documentclass[UTF8]{article}
\renewcommand{\listfigurename}{Figures}

\begin{document}

\listoffigures

\begin{figure}[!htp]
    \centering
    \fbox{  figure 1}
    \caption[The title of figure 1]{The detail in figure 1, which contains many special symbols and content details, is usually long and takes up multiple lines.}
\end{figure}
\begin{figure}[!htp]
    \centering
    \fbox{  figure 2}
    \caption[The title of figure 2]{The detail in figure 2, which contains many special symbols and content details, is usually long and takes up multiple lines.}
\end{figure}
\begin{figure}[!htp]
    \centering
    \fbox{  figure 3}
    \caption[The title of figure 3]{The detail in figure 3, which contains many special symbols and content details, is usually long and takes up multiple lines.}
\end{figure}
\end{document}

效果:
在这里插入图片描述

表格目录

和插图索引类似,在文章定义好表格之后,只需要使用“\listoftables”命令即可自动生成表格目录。
示例:

\documentclass[UTF8]{article}

\begin{document}

\listoftables

\begin{table}[h]
	\renewcommand{\arraystretch}{1.5}
	\caption{table 1}
	\centering
	\begin{tabular}{|c|c|}
        \hline
		a & b\\
        \hline
        c & d\\
        \hline
	\end{tabular}
\end{table}
\begin{table}[h]
	\renewcommand{\arraystretch}{1.5}
	\caption{table 2}
	\centering
	\begin{tabular}{|c|c|}
        \hline
		a & b\\
        \hline
        c & d\\
        \hline
	\end{tabular}
\end{table}
\begin{table}[h]
	\renewcommand{\arraystretch}{1.5}
	\caption{table 3}
	\centering
	\begin{tabular}{|c|c|}
        \hline
		a & b\\
        \hline
        c & d\\
        \hline
	\end{tabular}
\end{table}
\end{document}

效果:
在这里插入图片描述
修改表格目录标题的命令为“\renewcommand{\listtablename}{Tables}”,设定表格目录中的标题也和插图目录类似。

参考资料:
章节目录隐藏:https://jingyan.baidu.com/article/e8cdb32b3b2bee37052bade7.html
插图目录标题:http://blog.sina.com.cn/s/blog_5e16f1770100g5a3.html

### 调整 LaTeX 目录格式 对于 LaTeX 文档中的目录超出一页的情况,可以采取多种方法来优化和调整目录的布局。一种常见的解决方案是通过修改 `\tableofcontents` 的参数以及使用特定宏包实现更灵活的控制。 #### 使用 `titletoc` 宏包自定义目录样式 为了更好地管理多级标题并防止页面溢出,推荐引入 `titletoc` 宏包[^1]。此宏包允许用户精确设置各级条目的缩进量、字体大小和其他属性,从而确保整个目录结构紧凑而不失清晰度。 ```tex \usepackage{titletoc} % 设置章节项格式 \dottedcontents{section}[3.8em]{}{4.5em}{1pc} % 自定义节之间的间距及点线长度 ``` #### 控制目录宽度与换行行为 当遇到较长的章节名称时,可以通过设定合适的纸张尺寸或改变边距来增加可用空间;另外也可以让过长的文字自动折行而不是强制挤在同一行内造成视觉混乱: ```tex \usepackage[a4paper, margin=2cm]{geometry} % 设定合理的页边距 \setcounter{tocdepth}{2} % 只显示到二级子目 \renewcommand{\cftsecfont}{\normalfont} % 改变默认字体为正常体以便阅读 \let\oldtableofcontents=\tableofcontents \renewcommand{\tableofcontents}{ \begingroup \makeatletter \renewcommand*{\@pnumwidth}{2em} % 修改右侧页码栏位宽 \renewcommand*{\@tocrmarg}{3em plus1fil}% 增加右边界留白 \oldtableofcontents \endgroup } ``` 上述代码片段展示了如何利用 `titletoc` 和其他命令组合起来达到更好的效果。这些措施有助于保持良好的排版质量的同时解决了目录跨页的问题。
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值