Sem hifenização nas entradas do TOC, por favor

Sem hifenização nas entradas do TOC, por favor

Tenho títulos de seções muito longos e não quero que suas entradas no sumário sejam hifenizadas. saída de exemplo

\documentclass{scrreprt}
%\usepackage[ngerman]{babel}
\usepackage{tocloft}
\cftsetindents{section}{0mm}{12mm}
\cftsetindents{chapter}{0mm}{12mm}

\begin{document}
\tableofcontents
\chapter{Introduction}
\section{This kind of problem, that kind of problem, other ones and further considerations}
\section{More problems, even more problems, much worse than these, headline hyphenation, and blablablablablablablablabla and XYZ-blablablablablablablablabla}
\end{document}

Pesquisando no Google, tive a impressão de que \renewcommand{\cftsecfont}{\raggedright}deveria ajudar, mas não ajuda. Nem \begingroup \raggedright \tableofcontents \endgroupdea única resposta (não aceita) para uma pergunta relacionada. (Quando eu descomento \usepackage{ngerman]{babel}, a hifenização de "considerações" muda para "considerações", curiosamente.)

O problema ocorre também quando não utilizo tocloftou quando mudo a classe do documento para book, por exemplo (com hifenização em sílabas diferentes).

Posso fazer com que a hifenização no sumário desapareça completamente, sem precisar redefini-la para cada palavra ofensiva?! Pontos de bônus se a solução não fizer com que palavras longas ultrapassem a linha como o "blabla..." final, ainda mais pontos de bônus se combinações de palavras que contenham um hífen no início ("XYZ-blabla") puderem ser trazidas no mesma linha.

Responder1

Como você está usando uma classe KOMA, o caminho a seguir é usar otocstylepacote:

insira a descrição da imagem aqui

O código:

\documentclass{scrreprt}
\usepackage[ngerman]{babel}
\usepackage[tocflat]{tocstyle}

\newtocstyle{raggedstyle}{%
  \settocstylefeature[0]{entryhook}{\bfseries}
  \settocstylefeature[0]{leaders}{\hfill}
  \settocfeature{raggedhook}{\raggedright}
  \settocfeature{spaceafternumber}{17pt}
}
\usetocstyle{raggedstyle}

\begin{document}

\tableofcontents

\chapter{Introduction}
\section{This kind of problem, that kind of problem, other ones and further considerations}
\section{More problems, even more problems, much worse than these, headline with no hyphenation and somo more text goes here for the example}

\end{document}

Consulte a documentação do pacote para ajustes adicionais.

Responder2

Acho que estaria inclinado a usar a resposta de Gonzalo Medina, já que você está usando scrreprt(e pular o carregamento tocloft), mas uma tocloftsolução não é muito complicada (e também útil para memoiros usuários):

\documentclass{scrreprt}
\usepackage[ngerman]{babel}
\usepackage{tocloft}
\cftsetindents{section}{0mm}{12mm}
\cftsetindents{chapter}{0mm}{12mm}

\makeatletter
% \renewcommand{\@tocrmarg}{2.55em plus1fil}
\renewcommand{\@tocrmarg}{\@pnumwidth plus1fil} % <-- Revised
\makeatother

\begin{document}
\tableofcontents
\chapter{Introduction}
\section{This kind of problem, that kind of problem, other ones and further considerations}
\section{More problems, even more problems, much worse than these, headline hyphenation, and blablablablablablablablabla and XYZ-blablablablablablablablabla}

\end{document}

Você deve, em geral, certificar-se de que o valor revisado para \@tocrmarg(TOC Right MARGin) seja maior do que para \@pnumwidth(Page NUMber WIDTH).

Responder3

O uso do pacote tocloftjunto com uma classe KOMA-Script não é recomendado. Aqui está uma sugestão sem este pacote e sem a redefinição de um comando interno:

\documentclass{scrreprt}
\RedeclareSectionCommands[
  tocindent=0mm,
  tocnumwidth=12mm,
  tocraggedentrytext
]{chapter,section}

\begin{document}
\tableofcontents
\chapter{Introduction}
\section{This kind of problem, that kind of problem, other ones and further considerations}
\section{More problems, even more problems, much worse than these, headline hyphenation, and blablablablablablablablabla and XYZ-blablablablablablablablabla}
\end{document}

Resultado:

insira a descrição da imagem aqui

Você também pode usar a opção de classe toc=flatem vez de definir tocindent=0mme tocnumwidth=12mm:

\documentclass[toc=flat]{scrreprt}
\RedeclareSectionCommands[
  tocraggedentrytext
]{chapter,section}

\begin{document}
\tableofcontents
\chapter{Introduction}
\section{This kind of problem, that kind of problem, other ones and further considerations}
\section{More problems, even more problems, much worse than these, headline hyphenation, and blablablablablablablablabla and XYZ-blablablablablablablablabla}
\end{document}

Observe que há uma execução adicional necessária para o alinhamento.

Resultado:

insira a descrição da imagem aqui

Responder4

Uma solução com o titletocpacote:

\documentclass{scrreprt}
\usepackage[showframe]{geometry}
%\usepackage[ngerman]{babel}
\usepackage{ragged2e}
\usepackage{fmtcount}
\usepackage{titletoc}
 \titlecontents{chapter}[12mm]
 {\contentsmargin{10mm}\bigskip\sffamily\bfseries\Large}
 {\contentslabel[\MakeUppercase{\romannumeral\thecontentslabel}]{12mm}}
 {}
 {\hfill\contentspage}[\medskip]


 \titlecontents{section}[12mm]
 { \rightskip=10mm plus 1fil\hyphenpenalty=10000\contentsmargin{2mm}}%
 {\contentslabel[\thecontentslabel.]{12mm}}
 {}
 {\hskip2pt\titlerule*[6pt]{.}\contentspage}


\begin{document}
\tableofcontents

\setcounter{page}{100}
\chapter{Introduction}
\section{This kind of problem, that kind of problem, other ones and further considerations}
\section{More problems, even more problems, much worse than these, headline hyphenation, and blablablablablablablablabla and XYZblablablablablablablablabla}

\end{document} 

insira a descrição da imagem aqui

informação relacionada