如何在部分标题后添加一些空格?

如何在部分标题后添加一些空格?

这个帖子,我想知道如何修改文档各部分标题的布局。我想知道如何在部分标题的末尾和章节标题的开头之间插入空格。这是我的 MWE:

 \documentclass[hidelinks,12pt,twoside,openright,a4paper]{book}
    \setcounter{secnumdepth}{3}
    \setcounter{tocdepth}{3}
    \usepackage{setspace}
    \usepackage{lipsum}
    \usepackage{tocloft}
    \setlength{\cftbeforechapskip}{3pt}%espace entre chapitres
    \renewcommand{\cftchapleader}{\cftdotfill{\cftdotsep}} % for chapters
    
    \makeatletter
    \renewcommand\l@part[2]{%
      \ifnum \c@tocdepth >-2\relax
        \addpenalty{-\@highpenalty}%
        \addvspace{2.25em \@plus\p@}%
        \setlength\@tempdima{3em}%
        \begingroup
          \parindent \z@ \rightskip \@pnumwidth
          \parfillskip -\@pnumwidth
          {\hfill\parbox{0.6\linewidth}{\centering\large \bfseries #1}\hfill
           \hb@xt@\@pnumwidth{\hss #2%
                              \kern-\p@\kern\p@}}\par
           \nobreak
             \global\@nobreaktrue
             \everypar{\global\@nobreakfalse\everypar{}}%
        \endgroup
      \fi}
    
    \newcounter{partorder}
    \newcommand{\partorder}{%
    \ifcase\value{partorder}\or First\or Second\or Third\or Fourth\or Fifth\or Sixth\or Seventh\or Eighth\or Ninth\or Tenth\else ??(out range)\fi%
    } % If you have more than 10 parts, you need extend this define
    
    \def\@part[#1]#2{%
        \ifnum \c@secnumdepth >-2\relax
          \refstepcounter{part}\stepcounter{partorder}%
          \addcontentsline{toc}{part}{\texorpdfstring{\partorder\space\partname\\#1}{\partorder\space\partname\ --\ #1}}%
        \else
          \addcontentsline{toc}{part}{#1}%
        \fi
        \markboth{}{}%
        {\centering
         \interlinepenalty \@M
         \normalfont
         \ifnum \c@secnumdepth >-2\relax
           \huge\bfseries \partname\nobreakspace\thepart
           \par
           \vskip 20\p@
         \fi
         \Huge \bfseries #2\par}%
        \@endpart}
    \makeatother
    
    
    
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    
    \usepackage{fancyhdr}
    
    \pagestyle{fancy}
    % We don’t want chapter and section numbers
    \renewcommand{\chaptermark}[1]{\markboth{#1}{}}
    \renewcommand{\headrulewidth}{0pt}
    \fancyhf{} % sets both header and footer to nothing
    \fancyfoot{}
    \fancyhead[LE,RO]{\thepage}
    \fancyhead[CE]{\textit{A title}} % even pages: chapter title
    \fancyhead[CO]{\textit\leftmark} % odd pages: book title
    
    \setlength{\headheight}{15pt}
    \usepackage{hyperref}
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    
    \begin{document}
    \title{A title}
    \author{A name}
    \date{}
    \maketitle
    
    \tableofcontents
        
    \frontmatter
    \part{\texorpdfstring{Why is Latex so complicated?\\Answer and questions}{Why is Latex so complicated?\ --\ Answer and questions}}
    \chapter{A chapter}
    \lipsum
        
    \mainmatter
    \part{How to customize a part section?}
    \chapter{Another chapter}
    \lipsum
    
    \setcounter{part}{10}
    \setcounter{partorder}{10}
    \part{\texorpdfstring{How about more than 10 parts?\\You need define it in \textbackslash partorder command}{How about more than 10 parts?\ -- \ You need define it in \textbackslash partorder command}}
    \chapter{Another chapter}
    
    \backmatter
    
    \end{document}

相关内容