我正在使用 latex 制作大型报告,使用 article 类。到目前为止一切顺利。
问题是目录没有指向章节的正确页面。它对子章节很有效(据我所知,子章节太多了,无法全部尝试)。我在网上查了一下,所以我尝试了
\phantomsection
\addcontentsline{toc}{section}{Table of contents}
但这并没有什么帮助。
这就是我所拥有的:
\clearpage\phantomsection
\pagenumbering{gobble}% Remove page numbers (and reset to 1)
\pagenumbering{roman}%
\hypersetup{linkcolor=black}
\phantomsection
\addcontentsline{toc}{section}{Table of contents}
\tableofcontents
\newpage{}
\hypersetup{linkcolor=black}
\cleardoublepage\phantomsection
\listoffigures
\newpage{}
\hypersetup{linkcolor=black}
\cleardoublepage\phantomsection
\listoftables
我也尝试过这个:
% Try and fix wrong clicking
\usepackage[nottoc]{tocbibind}
但这也无济于事。
我的部分定义如下:
% custom section
\usepackage{titlesec}
\usepackage{tipa}
\titleformat{\section}
{\normalfont\huge\bfseries}
{\thesection\hskip 10pt\textpipe\hskip 10pt}
{0pt}
{}
% Continue on a new page after a section has finished
\newcommand{\sectionbreak}{\clearpage}
除此之外,我没有使用任何特殊的东西。有什么想法吗?
% Try and fix wrong clicking
\documentclass[11pt, twoside]{article}
\usepackage[nottoc]{tocbibind}
\usepackage{hyperref}
% custom section
\usepackage{titlesec}
\usepackage{tipa}
\titleformat{\section}
{\normalfont\huge\bfseries}
{\thesection\hskip 10pt\textpipe\hskip 10pt}
{0pt}
{}
% Continue on a new page after a section has finished
\newcommand{\sectionbreak}{\clearpage}
\begin{document}
\clearpage\phantomsection
\pagenumbering{gobble}% Remove page numbers (and reset to 1)
\pagenumbering{roman}%
\hypersetup{linkcolor=black}
\phantomsection
\addcontentsline{toc}{section}{Table of contents}
\tableofcontents
\newpage{}
\hypersetup{linkcolor=black}
\cleardoublepage\phantomsection
\listoffigures
\newpage{}
\hypersetup{linkcolor=black}
\cleardoublepage\phantomsection
\listoftables
\section{Introduction}
\pagenumbering{gobble}% Remove page numbers (and reset to 1)
\pagenumbering{arabic}
\end{document}
答案1
由于目前它是空的,所以后面应该至少有一个\clearpage
或一个命令,这样就不需要发出新的页面并从该页面开始,如果不想节省纸张的话,这可能不是有意的;-)\cleardoublepage
listoftables
\section{Introduction}
titlesec
由于该部分出现在错误的页面上,因此无论是否使用,该部分标题的隐含超目标也会放置在错误的页面上。
\documentclass[11pt, twoside]{article}
\usepackage[nottoc]{tocbibind}
\usepackage{hyperref}
% custom section
\usepackage{titlesec}
\usepackage{tipa}
\titleformat{\section}
{\normalfont\huge\bfseries}
{\thesection\hskip 10pt\textpipe\hskip 10pt}
{0pt}
{}
% Continue on a new page after a section has finished
\newcommand{\sectionbreak}{\clearpage}
\begin{document}
\clearpage\phantomsection
\pagenumbering{gobble}% Remove page numbers (and reset to 1)
\pagenumbering{roman}%
\hypersetup{linkcolor=black}
\phantomsection
\addcontentsline{toc}{section}{Table of contents}
\tableofcontents
\newpage{}
\hypersetup{linkcolor=black}
\cleardoublepage\phantomsection
\listoffigures
\newpage{}
\hypersetup{linkcolor=black}
\cleardoublepage\phantomsection
\listoftables
\cleardoublepage %%% Added here!!!!
\section{Introduction}
\pagenumbering{gobble}% Remove page numbers (and reset to 1)
\pagenumbering{arabic}
\end{document}
编辑其他版本没有,titlesec
为了保持|
节标题的风格
\documentclass[11pt]{article}
\usepackage[nottoc]{tocbibind}
\usepackage[demo]{graphicx}%
\usepackage{blindtext} %Can be removed later on
\usepackage{forloop} %Can be removed later on
\usepackage{caption}
\usepackage{etoolbox}%
\usepackage[bookmarksopen=true,bookmarksopenlevel=3,bookmarksnumbered=true]{hyperref}
\usepackage{bookmark}%
\newrobustcmd{\toggle}[1]{%
\iftoggle{#1}{\togglefalse{#1}}{\toggletrue{#1}}%
}%
\newtoggle{SectionAutoClearpage}%
\settoggle{SectionAutoClearpage}{true}%
\usepackage{tipa}
\newcommand{\sectionbreak}{%
\iftoggle{SectionAutoClearpage}{%
\clearpage%
}{%
% No, then do nothing here
}% End of \iftoggle
}% End of \sectionbreak%
\let\LaTeXStandardTheSection\thesection%
\let\LaTeXStandardSection\section
\newrobustcmd{\MySectionHeaderFormat}{\textpipe\hskip 10pt}
\makeatletter
\newcommand{\unstarredsection@opt}[2][]{%
\sectionbreak%
\LaTeXStandardSection[#1]{\MySectionHeaderFormat #1}%
}%
\newcommand{\unstarredsection@noopt}[1]{%
\unstarredsection[#1]{#1}%
}%
\newcommand{\starredsection}[1]{%
\LaTeXStandardSection*{#1}%
}%
\newcommand{\unstarredsection}{%
\@ifnextchar[{\unstarredsection@opt}{\unstarredsection@noopt}%
}%
\renewcommand{\section}{%
\@ifstar{\starredsection}{\unstarredsection}%
}%
\makeatother
\begin{document}
\clearpage\phantomsection
\pagenumbering{gobble}% Remove page numbers (and reset to 1)
\pagenumbering{roman}%
\hypersetup{linkcolor=black}
\phantomsection%
\addcontentsline{toc}{section}{Table of contents}
\tableofcontents
%\cleardoublepage\phantomsection
\listoffigures
%\cleardoublepage\phantomsection
\listoftables
%\togglefalse{SectionAutoClearpage} Disable it, just for fun%
\section{Introduction}
\pagenumbering{gobble}% Remove page numbers (and reset to 1)
\pagenumbering{arabic}
\blindtext
% Generate some dummy sections, just to show that the links work
%%% Anything after this can be removed, except \end{document} of course ;-)
\renewcommand{\thefigure}{\thesection.\arabic{figure}}
%\togglefalse{SectionAutoClearpage}%
\newcounter{seccounter}
\forloop{seccounter}{2}{\number\value{seccounter} < 21}{%
\toggle{SectionAutoClearpage}%
\section{Section Number \Roman{seccounter}}%
\blindtext
\includegraphics[width=4cm,height=4cm]{some_fig}%
\captionof{figure}{Dummy Figure number \Roman{seccounter}}
}%
\end{document}
解释:此解决方案比较困难,没有利用 KOMA 类的可能性
重新定义的节命令明确使用了未加星号的命令中section name prefix
的定义,但是,禁止在目录中使用此格式。 定义为,但也可以更改为节标题中允许的任何其他内容。\MySectionHeaderFormat
\section
\MySectionHeaderFormat
\textpipe\hskip 10pt
一旦\section
重新定义,就会出现抱怨,因为它与使用的命令\tableofcontents
不一致,所以只需强制回到旧命令就足够了,但必须明确说明,另一种方法是重新定义自身。\section*
\tableofcontents
\section*{}
\LaTeXStandardSection*
\tableofcontents
我引入了一个布尔切换标志SectionAutoClearpage
,它最初设置为 true,这样在新的部分开始之前就会有清除页面,只需\togglefalse{SectionAutoClearpage}
在任何适当的地方关闭此功能即可。
文档的最后一部分只是写了一些虚拟部分以显示新部分命令的效果。