是否可以仅为目录禁用连字符?

是否可以仅为目录禁用连字符?

我希望在文档中保留连字符,但在目录中将其禁用

此代码无效

\makeatletter
\renewcommand{\@tocrmarg}{2.55em plus1fil}
\makeatother

这是 MWE

\documentclass[a4paper,12pt]{report}
\usepackage{geometry}
\geometry{margin=2.5cm}
\usepackage{kantlipsum}
\linespread{1.2}

\usepackage[titles]{tocloft} %clear page TOC
\newcommand\Dotfill{\cftdotfill{\cftsecdotsep}}
\renewcommand{\cftchapleader}{\cftdotfill{\cftsecdotsep}}
\setcounter{secnumdepth}{-1}
\setcounter{tocdepth}{4}


%----------hypenation---------------------
\usepackage{hyphenat}
\emergencystretch=10pt      % allows some extra whitespace per line.
\exhyphenpenalty=100        % allows using hyphens which were already present.
% \hyphenpenalty=10000        % disables hyphens completly.

%-------------Title Chap & Section------------------------
\usepackage{titlesec}

\titleformat{\section}[block]{\filleft\bfseries\Large}{\thesection.}{0.5em}{}
\titleformat{\subsection}[block]{\filleft\bfseries\large}{\thesection.}{0.5em}{}
\titleformat{\subsubsection}[block]{\filleft\bfseries\large}{\thesection.}{0.5em}{}


\titleformat
{\chapter}                       % command
[display]                        % shape
{\Huge\bfseries\raggedleft}      % format
{}                               % label
{22pt}                           % separation between label and chapter-title
{\Huge}[\vspace{1ex}]            % before-code

\titleformat
{\section}                       % command
[display]                        % shape
{\Huge\bfseries\raggedleft}      % format
{}                               % label
{25pt}                           % separation between label and chapter-title
{\Huge}[\vspace{2ex}]            % before-code

% \titleformat{\section}{\bfseries\Large\raggedleft}{}{0.5em}{}
\titleformat{\subsection}{\bfseries\normalsize\raggedleft}{}{0.5em}{}
\titleformat{\subsubsection}{\bfseries\normalsize\raggedleft}{}{0.5em}{}

\titlespacing*{\chapter}{0pt}{\baselineskip}{\baselineskip}
\titlespacing*{\section}{0pt}{4ex}{1ex}
\titlespacing*{\subsection}{0pt}{0pt}{1ex}
\titlespacing*{\subsubsection}{0pt}{0pt}{6ex}

\newcommand{\autor}[1]{\textbf{\Large {#1}}\medskip\par}
\newcommand{\scoala}[1]{\textit{\normalsize{#1}}\medskip\par}
% \newcommand{\prof}[1]{\textit{\small prof. coord. {#1}}\\ \smallskip}

\newcommand{\prof}[1]{%
    \par\begingroup\linespread{1}\small\itshape
    \begin{tabular}[t]{@{}r@{}}#1\end{tabular}%
    \par\endgroup\smallskip
}

\begin{document}

\cftpagenumbersoff{part}
\cftsetrmarg{4cm}
\cftsetindents{part}{0cm}{1cm}
\cftsetindents{chapter}{1cm}{0cm}
\cftsetindents{section}{1cm}{0cm}
\cftsetindents{subsection}{2cm}{0cm}

\tableofcontents

\part{This is part I}

\chapter{Specii. Discurs și comportament politicianist în literatura noastră de secol XIX și XX}
\begin{flushright}
    \autor{Student Name}
    \scoala{Name of School}
    \prof{Professor 1}
\end{flushright}

\kant[1]
\end{document}

稍后编辑

我正在寻找一种优雅的方式来显示目录,即显示章节属于哪个部分。对我来说,连字符是一种丑陋的方式。我愿意接受任何能为集体文档显示优雅目录的建议。

答案1

在您的 MWE 中尝试一下,谢谢。

\bgroup    % keep non-hyphenation local to the ToC
\hyphenpenalty=10000
\tableofcontents
\egroup

处理您的 MWE 表明章节相对于目录中的部分是缩进的,因此您已经拥有了它。

在此处输入图片描述

相关内容