手动添加点填充

手动添加点填充

我手动向目录中添加了一个带有点的条目:

\addcontentsline{toc}{chapter}{\itshape{Contributors' Addresses}  \dotfill}

但是这会在我的书签中生成一个条目,其中包含贡献者的地址 to.44em。请看一下图片。我不知道 to.44em 是从哪里来的。

enter image description here

   \documentclass[10pt,final]{scrbook}
\usepackage{titletoc} % modify toc title
\usepackage{lipsum} % dummy text
\usepackage{anyfontsize} % change fontsize  
\usepackage{tocloft} % design toc
\usepackage{framed, xcolor}
\usepackage[english,ngerman]{babel}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{times}
\usepackage{helvet}
\usepackage{endnotes}
\usepackage{titlesec}

%%% Change the title of toc
%%% Change "Contents" size \small, \huge, \Large,... 
\addto\captionsngerman{\renewcommand{\contentsname}{\normalfont\slshape\large{Contents}}}

% section itshape
\titleformat*{\section}{\itshape}
\titleformat*{\subsection}{\itshape}
%\titleformat*{\tableofcontents}{\itshape}

% Spacing between section and text
% Syntax: \titlespacing*{<command>}{<left>}{<before-sep>}{<after-sep>}
\titlespacing*{\subsection}{0cm}{0.84cm}{0.42cm}

\titlespacing*{\section}{0cm}{0.84cm}{0.42cm}

% Spacing between chapter and author 
\titlespacing*{\chapter}{0cm}{0.84cm}{0.84cm}

% Spacing between chapterAndAuthor and section (?)
%\titlespacing*{\chapterAndAuthor}{0cm}{1.5cm}{1cm}

%%% Chapter style
\titleformat{\chapter}[display]
  {\normalfont}{\chaptertitlename\ \thechapter}{12pt}{\Large}

% Display chapters in the Table of Contents
\titlecontents{chapter}
  [0pt]% Left margin, optional
  {}% Code insertet above
  {\mdseries}% Numbered-entryformat
  {\mdseries}% Numberless-format
  {\contentspage\vskip1.5ex} % add dotfill and pagenumber, and some vertical space between entries

% Custom command to keep the author on the same page of chaptertitle, and above it.
\newcommand{\chapterAndAuthor}[2]{%
  % #1: Author
  % #2: Chaptertitle
  \clearpage
  % Keep the author and chaptertitle on same page
  \begingroup\let\cleardoublepage\relax\let\clearpage\relax
  % Set the author style
  {\fontsize{12}{14}\itshape \noindent #1}\par
  % Bring the chaptertitle closer to the authortitle
  \vspace{-0.21cm}
  % Add an entry to the Table of Contents, with the name of 
  % the author in emph and the chapter title
  \addcontentsline{toc}{chapter}{%
    \texorpdfstring{%
      \protect\parbox[b]{\dimexpr\textwidth-15.5pt}{
        {\normalfont\itshape {#1}}%
        \endgraf\vspace{0cm}
        \leftskip=1em #2 \dotfill
      }%
    }{#2}%
  }
  % Print the chapter
  \chapter*{#2}
  \endgroup
}

\pagestyle{plain}

\usepackage[pdftex]{graphicx}
\usepackage[pdftex]{graphics}
\usepackage{supertabular}

%SEITENLAYOUT%
 \usepackage[paperheight=21.0cm,paperwidth=13.5cm,twoside,textwidth=10.3cm,textheight=16.3cm,nohead,pdftex]{geometry}

%SCHRIFTGRÃSSEN%
\usepackage{fix-cm}

\makeatletter
\g@addto@macro\normalsize{\fontsize{10.0pt}{12.0pt}\selectfont} %\fontsize{Fontgröße}{Grundlinienabstand}
\g@addto@macro\footnotesize{\fontsize{9.0pt}{11.0pt}\selectfont} %\fontsize{Fontgröße}{Grundlinienabstand}
\makeatother


\usepackage[hyphens]{url}
\usepackage{multicol}
\usepackage[colorlinks=false, pdfborder={0 0 0}, breaklinks = true]{hyperref}
\urlstyle{same}



%%%%%%%%%%%%%%%%% end preambel %%%%%%%%%%%%%

\begin{document}

\tableofcontents
\clearpage


\chapterAndAuthor{The name of the first author, The name of second author and The name of the third author}{Test Chapter One Test Chapter One Test Chapter One Test Chapter One Test Chapter One Test Chapter One Test Chapter One}

\noindent\lipsum[1]

\chapterAndAuthor{Johanna von Orleans, Charles de Secondat, Baron de MontesquieuMontesquieu, , Albert Einstein}{Test Chapter Two Test Chapter Two Test Chapter Two Test Chapter Two Test Chapter Two Test Chapter Two Test Chapter Two}

\noindent\lipsum[1]

\chapterAndAuthor{The name of the first author, The name of second author and The name of the third author}{Test Chapter Three Test Chapter Three Test Chapter Three Test Chapter Three Test Chapter Three Test Chapter Three Test Chapter Three}

\noindent\lipsum[1]

\pagebreak

\subsection*{Contributors' Addresses}
  \phantomsection

  \addcontentsline{toc}{chapter}{Contributors' Addresses \dotfill}


\end{document}

答案1

您应该始终保护内部的非健壮宏,\addcontentsline否则它们的扩展将被写入.aux- 和.toc- 文件。

为了避免to.44em在书签中使用\texorpdfstring

  \addcontentsline{toc}{chapter}{Contributors'
    Addresses\protect\texorpdfstring{ \protect\dotfill}{}}

更改后,您至少需要运行两次 LaTeX 才能获得类似的结果:

bookmarks

您可以使用包bookmark在第一次运行 LaTeX 时立即更改书签。

顺便说一句:不建议使用toclofttitlesecscrbook

相关内容