附录单独目录

附录单独目录

我正在努力为我的附录创建一个单独的目录。

这是我目前拥有的:

目录
1 第一部分......1
2 第二部分......2
附录列表...5

这就是我想要实现的目标:

目录
1 第一部分......1
2 第二部分......2
附录列表...5

我的附录有单独的目录,包括所有部分:

附录列表
I 我的第一个附录......5
II 我的第二个附录......6

这是我目前的代码:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{hyperref}
\usepackage{lipsum}

\usepackage[toc,page]{appendix}

% as per https://tex.stackexchange.com/questions/100479/label-appendix-as-appendix-i-ii-iii-rather-than-appendix-a-b-and-c
\let\oldappendix\appendices
\renewcommand{\appendices}{%
  \clearpage
  \oldappendix
  \renewcommand{\thesection}{\Roman{section}}
  \addtocontents{toc}{\protect\setcounter{tocdepth}{0}}
  }%

% use custom names for appendices
\renewcommand{\appendixtocname}{List of appendices}
\renewcommand{\appendixpagename}{List of appendices}

\begin{document}

\tableofcontents
\section{first section}
\lipsum
\section{second section}
\lipsum

\begin{appendices}
    \section{My first appendix}
    \lipsum
    \section{My second appendix}
    \lipsum
\end{appendices}

\end{document}

非常感谢您的帮助。我尝试过用 解决我的问题minitoc,但是我没能实现我真正想要的。如果这是一个重复的问题,我真的很抱歉,但是我找不到针对我特定问题的答案。

答案1

在此处输入图片描述

Toc可以通过让.app(例如)文件句柄指向来实现附录条目的分离.toc,即在文档的某个点停止写入.toc文件并将所有内容输入.toc文件.app

我已经定义了一个 \listofappendices宏,它\tableofcontents通过重命名\contentsname和应用来重复使用\@starttoc{app},而不是\@starttoc{toc}

请注意,任何对的写入尝试.toc最终都将放入.app文件中,因此如果不希望这样,则必须在末尾恢复文件句柄appendices;这尚未完成。

\documentclass{article}
\usepackage{lipsum}
%\usepackage[utf8]{inputenc} % Not needed since TL 2018
\usepackage{hyperref}
\usepackage[page]{appendix}


% as per https://tex.stackexchange.com/questions/100479/label-appendix-as-appendix-i-ii-iii-rather-than-appendix-a-b-and-c

% use custom names for appendices

\renewcommand{\appendixtocname}{List of appendices}
\renewcommand{\appendixpagename}{Appendices}

\makeatletter
\let\oldappendix\appendices

\renewcommand{\appendices}{%
  \clearpage
  \renewcommand{\thesection}{\Roman{section}}
  % From now, everything goes to the app - file and not to the toc
  \let\tf@toc\tf@app
  \addtocontents{app}{\protect\setcounter{tocdepth}{1}}
  \immediate\write\@auxout{%
    \string\let\string\tf@toc\string\tf@app^^J
  }
  \oldappendix
}%



\newcommand{\listofappendices}{%
  \begingroup
  \renewcommand{\contentsname}{\appendixtocname}
  \let\@oldstarttoc\@starttoc
  \def\@starttoc##1{\@oldstarttoc{app}}
  \tableofcontents% Reusing the code for \tableofcontents with different \contentsname and different file handle app
  \endgroup
}

\makeatother


\begin{document}

\tableofcontents

\listofappendices



\section{first section}
\lipsum
\section{second section}
\lipsum

\section{Third section}
\lipsum




\begin{appendices}
    \section{My first appendix}
    \lipsum
    \section{My second appendix}
    \lipsum

    \section{My third appendix}
    \lipsum

\end{appendices}

\end{document}

更新恢复了在附录后写入原始目录的可能性的版本:

\documentclass{article}
\usepackage{lipsum}
%\usepackage[utf8]{inputenc} % Not needed since TL 2018
\usepackage[page]{appendix}
\usepackage{etoolbox}
\usepackage{hyperref}


% as per https://tex.stackexchange.com/questions/100479/label-appendix-as-appendix-i-ii-iii-rather-than-appendix-a-b-and-c

% use custom names for appendices

\setcounter{tocdepth}{3}
\renewcommand{\appendixtocname}{List of appendices}
\renewcommand{\appendixpagename}{Appendices}

\makeatletter
\let\oldappendix\appendices

\g@addto@macro\tableofcontents{%
  % Store the current toc file for later usage
  \let\tf@toc@orig\tf@toc
}
\renewcommand{\appendices}{%
  \clearpage
  \renewcommand{\thesection}{\Roman{section}}
  % From now, everything goes to the app - file and not to the toc
  \let\tf@toc\tf@app
  \addtocontents{app}{\protect\setcounter{tocdepth}{1}}
  \immediate\write\@auxout{%
    \string\let\string\tf@toc\string\tf@app
  }
  \oldappendix
}%

\g@addto@macro\endappendices{%
  % Switch back to the old toc file handle
  \let\tf@toc\tf@toc@orig
  \immediate\write\@auxout{%
    \string\let\string\tf@toc\string\tf@toc@orig
  }%
}  

\newcommand{\listofappendices}{%
  \begingroup
  \renewcommand{\contentsname}{\appendixtocname}
  \let\@oldstarttoc\@starttoc
  \def\@starttoc##1{\@oldstarttoc{app}}
  \tableofcontents% Reusing the code for \tableofcontents with different \contentsname and different file handle app
  \endgroup
}

\makeatother


\begin{document}

\tableofcontents

\listofappendices



\section{first section}
\lipsum
\section{second section}
\lipsum

\section{Third section}
\lipsum




\begin{appendices}
    \section{My first appendix}
    \lipsum
    \section{My second appendix}
    \lipsum

    \section{My third appendix}
    \lipsum

\end{appendices}

\section{A section after the appendices}

\end{document}

在此处输入图片描述

相关内容