我正在使用文档类"report“和包{tocloft}。我在更改由"\tableofcontents“生成的目录中明确显示的章节、章节和子章节的字体大小时遇到问题。它实际上是采用内容的大小,因为它们存在于报告中,但我想改变目录页面的字体大小。
\documentclass{report}
\usepackage{tocloft,lipsum,pgffor}
\setcounter{tocdepth}{3}% Include up to \subsubsection in ToC
\renewcommand{\cftpartfont}{\normalfont\sffamily\bfseries}% \part font in ToC
\renewcommand{\cftchapfont}{\normalfont\large\itshape} % \chapter font in ToC
\renewcommand{\cftsecfont}{\normalfont\slshape} % \section font in ToC
\renewcommand{\cftsubsecfont}{\normalfont\itshape} % \subsection font in ToC
\renewcommand{\cftsubsubsecfont}{\normalfont\small} % \subsubsection font in ToC
\begin{document}
\tableofcontents% ToC
% Create a dummy document with multiple (5) levels of sectional units
\foreach \curpart in {\Huge First, Second, Third, Last} {
\part{\curpart{} part}
\foreach \curchap in {\huge First, Second, Third, Last} {
\chapter{\curchap{} chapter} \lipsum[1]
\foreach \cursec in {\LARGE First, Second, Third, Last} {
\section{\cursec{} section}\lipsum[2]
\foreach \cursubsec in {First, Second, Third, Last} {
\subsection{\cursubsec{} subsection}\lipsum[3]
\foreach \cursubsubsec in {First, Second, Third, Last} {
\subsubsection{\cursubsubsec{} subsubsection}\lipsum[4]
}% \subsubsection
}% \subsection
}% \section
}% \chapter
}% \part
\end{document}我已经在虚拟文档的章节标题中添加了\huge和\LARGE。
\foreach \curchap in {\huge First, Second, Third, Last} {
\chapter{\curchap{} chapter} \lipsum[1]
\foreach \cursec in {\LARGE First, Second, Third, Last} {这样做还反映了TOC页面中该部分标题的大小更改。Before adding \huge and \LARGE inside the section heading
我想让TOC页面中的章节和章节标题的字体大小独立于文档中发生的事情。
发布于 2017-12-05 03:28:42
您应该避免在部分单元标题中使用字体更改,因为这些更改在默认情况下会进入ToC。对于奇怪的字体更改,我建议使用
\section[<ToC entry>]{<document entry>}你可以在<document entry>中指定任何你想要的东西,但是让<ToC entry>保持不变的字体。有关为截面单位设置字体的更全面的方法,请使用分别为<ToC entry>和<document entry>提供字体设置挂钩的软件包。
使用sectsty或titlesec可以轻松地更改<document entry>字体,而通常使用tocloft或titletoc进行<ToC entry>更改。特定于sectsty,为截面单位X重新定义\Xfont。例如,
\renewcommand{\partfont}{\normalfont\Huge\bfseries}将仅影响\part的<document content>,保持<ToC entry>不变(并且不更改字体)。
对于ToC中的每个章节单元X,tocloft提供了\cftZfont,其中X表示(来自tocloft documentation的2.3节排版条目):
part for titleschap titlessec for titlessubtab titlessubsubsec titlespara for \subsection titlesfig for titlessubfig for titlestab titlessubpara for \part titlessubfig for \section \subsectiontitlesfig for \paragraph titlestab for \section\subsectiontitlesfig for \subsubsection titlessubfig for \subparagraph \caption \caption \section\subsection<代码>D64for subtable \caption标题以下是如何更改与不同截面单位关联的各种组件的示例:

\documentclass{report}
\usepackage{tocloft,lipsum,pgffor,sectsty}
\setcounter{tocdepth}{3}% Include up to \subsubsection in ToC
% Font changes to ToC content of sectional units
\renewcommand{\cftpartfont}{\normalfont\sffamily\bfseries}% \part font in ToC
\renewcommand{\cftchapfont}{\normalfont\large\itshape} % \chapter font in ToC
\renewcommand{\cftsecfont}{\normalfont\slshape} % \section font in ToC
\renewcommand{\cftsubsecfont}{\normalfont\itshape} % \subsection font in ToC
\renewcommand{\cftsubsubsecfont}{\normalfont\small} % \subsubsection font in ToC
% Font changes to document content of sectional units
\renewcommand{\partfont}{\normalfont\Huge\bfseries}
\renewcommand{\chapterfont}{\normalfont\huge\bfseries}
\renewcommand{\sectionfont}{\normalfont\LARGE\bfseries}
\begin{document}
\tableofcontents% ToC
% Create a dummy document with multiple (5) levels of sectional units
\foreach \curpart in {First, Second, Third, Last} {
\part{\curpart{} part}
\foreach \curchap in {First, Second, Third, Last} {
\chapter{\curchap{} chapter} \lipsum[1]
\foreach \cursec in {First, Second, Third, Last} {
\section{\cursec{} section}\lipsum[2]
\foreach \cursubsec in {First, Second, Third, Last} {
\subsection{\cursubsec{} subsection}\lipsum[3]
\foreach \cursubsubsec in {First, Second, Third, Last} {
\subsubsection{\cursubsubsec{} subsubsection}\lipsum[4]
}% \subsubsection
}% \subsection
}% \section
}% \chapter
}% \part
\end{document}https://stackoverflow.com/questions/47604626
复制相似问题