
非常に長いセクション タイトルがいくつかあり、目次内のエントリをハイフンで区切らないようにしたいです。
\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}
グーグルで調べたところ、役に立つような気がしたが、役に立た\renewcommand{\cftsecfont}{\raggedright}
なかった。\begingroup \raggedright \tableofcontents \endgroup
関連する質問に対する唯一の(受け入れられない)回答(コメントを外すと\usepackage{ngerman]{babel}
、「consid-erations」のハイフンが「consid-derations」に変わるのが興味深いです。)
この問題は、 を使用しない場合や、たとえばtocloft
ドキュメント クラスを に変更した場合(異なる音節でハイフンが使用される場合) にも発生します。book
問題のある単語ごとにハイフネーションを再定義することなく、目次のハイフネーションを完全になくすことはできますか? 解決策によって、最後の「blabla...」のように長い単語が行をまたがることがない場合はボーナス ポイントが付与されます。また、最初からハイフンを含む単語の組み合わせ (「XYZ-blabla」) を同じ行にまとめることができれば、さらにボーナス ポイントが付与されます。
答え1
KOMAクラスを使用しているので、tocstyle
パッケージ:
コード:
\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}
さらなる調整については、パッケージのドキュメントを参照してください。
答え2
scrreprt
を使用している場合(および読み込みをスキップする場合) 、Gonzalo Medina の回答を使用する傾向があると思いますtocloft
が、tocloft
解決策はそれほど難しくありません(memoir
ユーザーにとっても便利です)。
\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}
一般的に、(TOC Right MARGin) の修正値が(Page NUMber WIDTH)\@tocrmarg
の値よりも大きいことを確認する必要があります。\@pnumwidth
答え3
tocloft
パッケージをKOMA-Script クラスと一緒に使用することは推奨されません。このパッケージを使用せず、内部コマンドを再定義しない場合の提案を以下に示します。
\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}
結果:
toc=flat
設定の代わりにクラス オプションを使用することもできますtocindent=0mm
: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}
アライメントには追加の実行が必要であることに注意してください。
結果:
答え4
パッケージによるソリューションtitletoc
:
\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}