![如何在目录中为章节(及其部分等)添加多标签?](https://linux22.com/image/371143/%E5%A6%82%E4%BD%95%E5%9C%A8%E7%9B%AE%E5%BD%95%E4%B8%AD%E4%B8%BA%E7%AB%A0%E8%8A%82%EF%BC%88%E5%8F%8A%E5%85%B6%E9%83%A8%E5%88%86%E7%AD%89%EF%BC%89%E6%B7%BB%E5%8A%A0%E5%A4%9A%E6%A0%87%E7%AD%BE%EF%BC%9F.png)
由于第二章只包含简短的章节等,我希望仅有的第二章多栏。
我BeforeStartingTOC[toc]{\begin{multicols}{2}} \AfterStartingTOC[toc]{\end{multicols}}
只得到了两列的整个目录。
这是 MWE:
\documentclass[twoside=false,listof=totoc,listof=leveldown]{scrbook}
\usepackage{multicol}
\begin{document}
% \BeforeStartingTOC[toc]{\begin{multicols}{2}}
% \AfterStartingTOC[toc]{\end{multicols}}
\tableofcontents
\chapter{long long long long long long long long long long long chapter}
\section{long long long long long long long long long long long section}
\section{long long long long long long long long long long long section}
\section{long long long long long long long long long long long section}
\chapter{short chapter}
\section{short section}
\section{short section}
\section{short section}
\section{short section}
\section{short section}
\section{short section}
\section{short section}
\section{short section}
\section{short section}
\section{short section}
\section{short section}
\section{short section}
\chapter{long long long long long long long long long long long chapter}
\section{long long long long long long long long long long long section}
\section{long long long long long long long long long long long section}
\section{long long long long long long long long long long long section}
\end{document}
答案1
您可以使用\addtocontents
:
\documentclass[twoside=false,listof=totoc,listof=leveldown]{scrbook}
\usepackage{multicol}
\begin{document}
% \BeforeStartingTOC[toc]{\begin{multicols}{2}}
% \AfterStartingTOC[toc]{\end{multicols}}
\tableofcontents
\chapter{long long long long long long long long long long long chapter}
\section{long long long long long long long long long long long section}
\section{long long long long long long long long long long long section}
\section{long long long long long long long long long long long section}
\addtocontents{toc}{\protect\begin{multicols}{2}}
\chapter{short chapter}
\section{short section}
\section{short section}
\section{short section}
\section{short section}
\section{short section}
\section{short section}
\section{short section}
\section{short section}
\section{short section}
\section{short section}
\section{short section}
\section{short section}
\addtocontents{toc}{\protect\end{multicols}}
\chapter{long long long long long long long long long long long chapter}
\section{long long long long long long long long long long long section}
\section{long long long long long long long long long long long section}
\section{long long long long long long long long long long long section}
\end{document}
我认为更好看:
\documentclass[twoside=false,listof=totoc,listof=leveldown]{scrbook}
\usepackage{multicol}
\begin{document}
% \BeforeStartingTOC[toc]{\begin{multicols}{2}}
% \AfterStartingTOC[toc]{\end{multicols}}
\tableofcontents
\chapter{long long long long long long long long long long long chapter}
\section{long long long long long long long long long long long section}
\section{long long long long long long long long long long long section}
\section{long long long long long long long long long long long section}
\chapter{short chapter}
\addtocontents{toc}{\protect\bgroup\protect\multicolsep=0pt\protect\begin{multicols}{2}}
\section{short section}
\section{short section}
\section{short section}
\section{short section}
\section{short section}
\section{short section}
\section{short section}
\section{short section}
\section{short section}
\section{short section}
\section{short section}
\section{short section}
\addtocontents{toc}{\protect\end{multicols}\protect\egroup}
\chapter{long long long long long long long long long long long chapter}
\section{long long long long long long long long long long long section}
\section{long long long long long long long long long long long section}
\section{long long long long long long long long long long long section}
\end{document}