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