如何在目录中添加“假”附件

如何在目录中添加“假”附件

我想将附件添加到目录中,但不想将它们添加到我的 latex 文件中。因此,我只想添加类似以下内容的内容:

**Attachments**
Attachment A: interview .............................. 1
Attachment B: worddoc ................................ 5

所以我可以将 Word 文件与 Latex 文件分开打印。

提前致谢

我的文件:

\documentclass[11 pt, twoside, openright, tikz]{report}
\begin{document}
{\let\cleardoublepage\clearpage
\tableofcontents} %error here
\addcontentsline{toc}{chapter}{Referenties}
\bibliographystyle{apalike}
\end{document}

给出错误:

Runaway argument?
File ended while scanning use of \contentsline.
<inserted text> 
                \par 
l.131 \tableofcontents
                      }

答案1

带页码的示例

附件添加在文档/目录的末尾。由于最后一页之后延迟书写将不起作用,因此书写方式更改\immediate\write\zref@wrapper@immediate

\documentclass{report}
\usepackage{zref-base}

\begin{document}
\tableofcontents
\chapter{Regular chapter}
\section{Regular section}

\clearpage
\begingroup
  \makeatletter
  \def\addtoc#1#2#3{%
    \addtocontents{toc}{%
      \protect\contentsline{#1}{#2}{#3}%
    }%
  }%
  \zref@wrapper@immediate{%
    \addtoc{chapter}{Attachments}{}%
    \addtoc{section}{Attachment A: interview}{\the\numexpr\value{page}-1+1\relax}%
    \addtoc{section}{Attachment B: worddoc}{\the\numexpr\value{page}-1+5\relax}%
  }%
\endgroup
\end{document}

带页码的结果

没有页码和点的示例

\NoDottedTocLine插入到.toc文件中以删除点。

\documentclass{report}
\usepackage{zref-base}
\makeatletter
\def\@tocline#1#2#3#4#5{%
  \ifnum #1>\c@tocdepth \else
    \vskip \z@ \@plus.2\p@
    {\leftskip #2\relax \rightskip \@tocrmarg \parfillskip -\rightskip
     \parindent #2\relax\@afterindenttrue
     \interlinepenalty\@M
     \leavevmode
     \@tempdima #3\relax
     \advance\leftskip \@tempdima \null\nobreak\hskip -\leftskip
     {#4}\nobreak
     % \leaders\hbox{$\m@th
     %    \mkern \@dotsep mu\hbox{.}\mkern \@dotsep
     %    mu$}%
     \hfill
     \nobreak
     \hb@xt@\@pnumwidth{\hfil\normalfont \normalcolor #5}%
     \par}%
  \fi
}
\newcommand*{\NoDottedTocLine}{%
  \let\@dottedtocline\@tocline
}
\makeatother

\begin{document}
\tableofcontents
\chapter{Regular chapter}
\section{Regular section}

\clearpage
\begingroup
  \makeatletter
  \def\addtoc#1#2#3{%
    \addtocontents{toc}{%
      \protect\contentsline{#1}{#2}{#3}%
    }%
  }%
  \zref@wrapper@immediate{%
    \addtocontents{toc}{\protect\NoDottedTocLine}%
    \addtoc{chapter}{Attachments}{}%
    \addtoc{section}{Attachment A: interview}{}%
    \addtoc{section}{Attachment B: worddoc}{}%
  }%
\endgroup
\end{document}

结果

相关内容