如何在目录中插入不带缩进的换行符

如何在目录中插入不带缩进的换行符

这是我正在尝试的代码:

\documentclass{book}

\begin{document}

\chapter{Chapter one}

\chapter*{\emph{Chapter two}}
\addcontentsline{toc}{chapter}{\setlength\parindent{24pt}Chapter two\\ Explanations on Chapter two}

\tableofcontents

\end{document} 

问题\\是新行缩进,我试过了\linebreak,但它不接受

答案1

tocbasic以下是使用包并声明新的 tocentry 的建议:

\documentclass{book}

\usepackage{tocbasic}
\DeclareTOCStyleEntry[
  level=0,
  beforeskip=1em plus 1pt,
  indent=0pt,
  numwidth=0pt,
  linefill=\hfill,
  entryformat=\textbf,
  pagenumberformat=\textbf,
]{tocline}{bchap}

\begin{document}
\chapter{Chapter one}

\chapter*{\emph{Chapter two}}
\addcontentsline{toc}{bchap}{Chapter two\\Explanations on Chapter two}

\chapter{Chapter three}
\tableofcontents
\end{document}

结果:

在此处输入图片描述


如果章节条目和页码之间应该有点,则可以使用

\documentclass{book}

\usepackage{tocbasic}
\DeclareTOCStyleEntry[
  level=0,
  beforeskip=1em plus 1pt,
  indent=0pt,
  numwidth=0pt,
  entryformat=\textbf,
  pagenumberformat=\textbf,
]{tocline}{bchap}
\DeclareTOCStyleEntry[
  linefill=\TOCLineLeaderFill,
  pagenumberformat=\textbf
]{tocline}{chapter}

\begin{document}
\chapter{Chapter one}

\chapter*{\emph{Chapter two}}
\addcontentsline{toc}{bchap}{Chapter two\\Explanations on Chapter two}

\chapter{Chapter three}
\tableofcontents
\end{document}

结果:

在此处输入图片描述

答案2

这是一个选项tocloft

在此处输入图片描述

\documentclass{book}

\usepackage{tocloft}
\renewcommand{\cftchapdotsep}{5}% Add dots for \chapters

\begin{document}

\tableofcontents

\chapter{Chapter one}

\chapter*{\emph{Chapter two}}
\addcontentsline{toc}{chapter}{%
  Chapter two \\ \protect\hspace*{-\cftchapnumwidth}Explanations on Chapter two}

\tableofcontents

\end{document}

相关内容