
Tenho títulos de seções muito longos e não quero que suas entradas no sumário sejam hifenizadas.
\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 \endgroup
dea ú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 tocloft
ou 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 otocstyle
pacote:
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 tocloft
solução não é muito complicada (e também útil para memoir
os 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 tocloft
junto 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:
Você também pode usar a opção de classe toc=flat
em vez de definir tocindent=0mm
e 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:
Responder4
Uma solução com o titletoc
pacote:
\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}