如何强制 Latex 将目录行保持在页边距内?

如何强制 Latex 将目录行保持在页边距内?

我的目录中有一行有点太长,但是乳胶不会将其识别为新行:

在 Latex 代码中,这是:

\subsection{Lineares Positioniersystem mit Waage und 3D-Lasertriangulationssensor}

我的目录设置如下:

\usepackage{interfaces}
\usepackage[titles]{tocloft}
\tocsetup{
    title/font = \huge\color{blue},
    chapter/number/after = .,
    chapter/number/width=8mm,   
    section/number/after = .,
    section/indent = 8mm,
    section/number/width=10mm,
    subsection/indent=18mm,
    subsection/number/after = .,
    subsection/number/width=12mm
}

有人知道如何解决这个问题吗?谢谢!

答案1

TeX 尝试将小节标题放在文本区域内,但未能成功,因为它在“3D-Lasertriangulationssensor”中找不到合适的连字符点。这是因为默认情况下,包含连字符的单词不会在任何其他位置连字符。快速解决方案是告诉 TeX 这个单词在哪里可以连字符\-

\subsection{Lineares Positioniersystem mit Waage und 3D-La\-ser\-tri\-an\-gu\-la\-tions\-sen\-sor}

使用 KOMA 脚本设置与您的 ToC 类似的完整文档:

\documentclass[
        a4paper,
        11pt,
        parskip=half-,
        oneside,
        listof=totoc,
        bibliography=numbered,
        headings=big,
        appendixprefix=true
    ]{scrreprt}

\usepackage{xcolor}

\usepackage{blindtext}% for dummy text

\setkomafont{partentry}{\large\bfseries\color{blue}}
\RedeclareSectionCommand
  [%
    ,tocnumwidth=8mm
  ]{part}
\RedeclareSectionCommand
  [%
    ,tocindent=8mm
    ,tocnumwidth=8mm
  ]{chapter}
\RedeclareSectionCommand
  [%
    ,tocindent=16mm
    ,tocnumwidth=10mm
  ]{section}
\RedeclareSectionCommand
  [%
    ,tocindent=26mm
    ,tocnumwidth=10mm
  ]{subsection}
\RedeclareSectionCommand
  [%
    ,tocindent=36mm
    ,tocnumwidth=13mm
  ]{subsubsection}
\DeclareTOCStyleEntry
  [%
    numwidth=13mm
  ]{tocline}{figure}
\DeclareTOCStyleEntry
  [%
    numwidth=13mm
  ]{tocline}{table}

\BeforeTOCHead{\addtokomafont{chapter}{\huge\color{blue}}}

\begin{document}    
\pagenumbering{Roman}
Some beginning text
\renewcommand{\contentsname}{Inhaltsverzeichnis}
\tableofcontents
\cleardoublepage

\part{FOOOBAR}
\pagenumbering{arabic}
Some Text included by "include commands"
\listoftables
\listoffigures
\cleardoublepage
\Blinddocument
\subsection{Lineares Positioniersystem mit Waage und 3D-La\-ser\-tri\-an\-gu\-la\-tions\-sen\-sor}
\captionof{figure}{foobar}
\captionof{table}{foobar}
\end{document}

生成的目录:

在此处输入图片描述

相关内容