我设法自定义了文档中各部分的目录条目的字体格式。
如何在 scrartcl (KOMA) 的帮助下设置以下级别的格式?这是否可行,还是我需要使用类似的包tocloft
?
(旁注:在文档中使用取消注释\footnotesize
会导致只设置该字体大小的文本,而不设置页码。)
平均能量损失
\documentclass[
11pt,
a4paper,
]
{scrartcl}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\pdfgentounicode=1
\usepackage{multicol}
\addtokomafont{sectionentry}{\footnotesize}
\addtokomafont{sectionentrydots}{\footnotesize}
\addtokomafont{sectionentrypagenumber}{\footnotesize}
%\addtokomafont{subsectionentry}{\footnotesize}
%\addtokomafont{subsectionentrydots}{\footnotesize}
%\addtokomafont{subsectionentrypagenumber}{\footnotesize}
\listfiles
\begin{document}
\begin{multicols*}{2}
%\footnotesize
\tableofcontents
%\normalsize
\section{AAAAAAAA}
\subsection{aaaaaaa}
\subsection{bbbbbb}
\section{BBBBB}
\subsection{cccccccccc}
\subsection{d}
\subsection{e}
\end{multicols*}
\end{document}
答案1
您可以使用\RedeclareSectionCommands
:
\RedeclareSectionCommands[
tocentryformat=\footnotesize,
toclinefill=\footnotesize\TOCLineLeaderFill,
tocpagenumberformat=\footnotesize
]{subsection,subsubsection,paragraph,subparagraph}
例子:
\documentclass[
%11pt,% default
%a4paper,% default
sectionentrydots% enable dots for section entries
]
{scrartcl}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
%\usepackage[utf8]{inputenc}% needed for older TeX distributions
%\pdfgentounicode=1% not needed in the example
\usepackage{multicol}
\addtokomafont{sectionentry}{\footnotesize}
\addtokomafont{sectionentrydots}{\footnotesize}% option sectionentrydots is needed to enable the dots
\addtokomafont{sectionentrypagenumber}{\footnotesize}
\RedeclareSectionCommands[
tocentryformat=\footnotesize,
toclinefill=\footnotesize\TOCLineLeaderFill,
tocpagenumberformat=\footnotesize
]{subsection,subsubsection,paragraph,subparagraph}
\listfiles
\begin{document}
\begin{multicols*}{2}
\tableofcontents
\section{AAAAAAAA}
\subsection{aaaaaaa}
\subsection{bbbbbb}
\section{BBBBB}
\subsection{cccccccccc}
\subsection{d}
\subsection{e}
\end{multicols*}
\end{document}
补充说明
\addtokomafont{sectionentry}{\footnotesize}
\addtokomafont{sectionentrydots}{\footnotesize}% option sectionentrydots is needed to enable the dots
\addtokomafont{sectionentrypagenumber}{\footnotesize}
相当于
\RedeclareSectionCommand[
tocentryformat=\usekomafont{disposition}\footnotesize,
toclinefill=\footnotesize\TOCLineLeaderFill,
tocpagenumberformat=\usekomafont{disposition}\footnotesize
]{section}
第二个版本无需选项即可工作sectionentrydots
。
答案2
我在此期间研究了另一种方法,使用tocloft
:
图片
平均能量损失
\documentclass[
11pt,
a4paper,
]
{scrartcl}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\pdfgentounicode=1
\usepackage{multicol}
\usepackage{tocloft}
\renewcommand{\cftsecfont}{\footnotesize\sffamily\bfseries}
\renewcommand{\cftsecpagefont}{\footnotesize\sffamily\bfseries}
\renewcommand{\cftsubsecfont}{\footnotesize}
\renewcommand{\cftsubsecpagefont}{\footnotesize\sffamily}
\setlength{\cftbeforesecskip}{2pt}
\renewcommand{\cftsecafterpnum}{\vspace{-2pt}}
\setlength{\cftbeforesubsecskip}{-1pt}
\setlength{\cftaftertoctitleskip}{3pt}
\renewcommand{\cftsecdotsep}{\cftdotsep}
\listfiles
\begin{document}
\begin{multicols*}{2}
\tableofcontents
\section{AAAAAAAA}
\subsection{aaaaaaa}
\subsection{bbbbbb}
\section{BBBBB}
\subsection{cccccccccc}
\subsection{d}
\subsection{e}
\end{multicols*}
\end{document}