问题
使用 latex 模板,目录设置有诸多不如意的地方。经过一番学习,记录下常用见问题与解决命令
创建目录
分别创建了 目录,图目录,表目录。 由于 摘要等放在目录前,罗马数字编号也是从摘要编码,所以此处 \pagenumbering{roman} \setcounter{page}{1}
被注释掉了。
\cleardoublepage %\pagenumbering{roman} \setcounter{page}{1} % Page number is set before
\tableofcontents
\cleardoublepage \listoffigures
\cleardoublepage \listoftables
目录没有“摘要”等未编号的章节
在“摘要”这一章后面添加 \addcontentsline{toc}{chapter}{Abstract}
。在之前添加会导致点击目录“摘要”项链接到前一页。
\chapter*{Abstract}
\addcontentsline{toc}{chapter}{Abstract} % show the "abstract" in contents, place this line after the chapter/section created
解决目录页中添加条目后,链接到错误页码的问题
使用 \addcontentsline{toc}{chapter}{Contents}
可以添加 “目录”这一项到目录页,但是会导致点击“Contents”这一项会链接到前一页。这个问题可以使用 \phantomsection
解决,注意必须把 \phantomsection
放到 \addcontentsline{toc}{chapter}{Contents}
前面。
\cleardoublepage %\pagenumbering{roman} \setcounter{page}{1} % Page number is set before
\phantomsection % use \phantomsection before \addcontentsline for content hyperlink to wrong pages
\addcontentsline{toc}{chapter}{Contents}
\tableofcontents
\cleardoublepage \listoffigures
\cleardoublepage \listoftables
- Table of Contents links to wrong pages + Wrong header name
- Latex Table of Contents Links to Wrong Section
目录页中章标题后面没有点延续到页码
使用 \renewcommand\cftchapdotsep{\cftdotsep}
给目录的章标题后面添加点延续到页码。需要头文件 \usepackage[subfigure]{tocloft}
,注意如果有报错,尝试加载 subfigure
这个选项。
% add dotted line to the chapter without numbering, must "Load the tocloft package with the option subfigure."
\usepackage[subfigure]{tocloft}
\renewcommand\cftchapdotsep{\cftdotsep}
- Adding dotted lines to the LOF and LOT
- tocloft does not work with list of subfigure in List of Figure?
书签
书签导航栏可以快速定位到文章具体位置,也需要设置。此处设置 标题页 书签。
- 只设置书签,不在目录中显示。
\pdfbookmark[0]{Title Page}{*}
或者
\pdfbookmark[0]{Title Page}{title}
- 需要标题页出现在目录,使用前面提到的添加到目录的方法。
% \phantomsection % use \phantomsection before \addcontentsline for content hyperlink to wrong pages
% \addcontentsline{toc}{chapter}{Title Page}
参考
- Pdfbookmark for abstract and table of contents (toc)
- Understanding
\pdfbookmark
- PDF information and navigation elements with hyperref, pdfTEX, and thumbpdf
备注
可能缺少部分头文件,相应查询上述命令的头文件并添加,没法提供模板。