附录分隔页罗马数字

附录分隔页罗马数字

我想继续用罗马字体对附录进行编号。但如果我之后切换\begin{appendices}到罗马字体,分隔页将不包含在内。如果我在附录之前切换编号,我的最后一章也会使用罗马字体编号。我可以从分隔页开始切换到罗马字体吗?

\documentclass[a4paper,12pt,oneside]{report}
\usepackage[toc,page]{appendix}
\newcounter{savepage}
\begin{document}
  \pagenumbering{Roman}
  \pagestyle{plain}

  \tableofcontents
  \cleardoublepage

  \chapter{Introduction}
  \setcounter{savepage}{\arabic{page}}
  \pagenumbering{arabic}
  \chapter{Conclusion and Outlook}\label{ch_conclusion}

  \begin{appendices}
    \pagenumbering{Roman}
    \setcounter{page}{\thesavepage}
    \addtocontents{toc}{\protect\setcounter{tocdepth}{1}}
    \makeatletter
    \addtocontents{toc}{%
        \begingroup
        \let\protect\l@chapter\protect\l@section
        \let\protect\l@section\protect\l@subsection
    }
    \makeatother        
    \addtocontents{toc}{\endgroup}      
  \end{appendices}
\end{document}

感谢您的帮助!

答案1

使用\cleardoublepage后跟之前页码的改变\begin{appendices}

\documentclass[a4paper,12pt,oneside]{report}
\usepackage[toc,page]{appendix}
\newcounter{savepage}
\begin{document}
  \pagenumbering{Roman}
  \pagestyle{plain}
  \tableofcontents
  %\cleardoublepage
  \chapter{Introduction}

  \cleardoublepage
  \setcounter{savepage}{\value{page}}
  \pagenumbering{arabic}
  \chapter{Conclusion and Outlook}\label{ch_conclusion}

  \cleardoublepage
  \pagenumbering{Roman}
  \setcounter{page}{\value{savepage}}
  \begin{appendices}
    \addtocontents{toc}{\value{tocdepth}=1}
    \makeatletter
    \addtocontents{toc}{%
        \begingroup
        \let\protect\l@chapter\protect\l@section
        \let\protect\l@section\protect\l@subsection
    }
    \makeatother
    \chapter{Appendix chapter}
    \section{Appendix section}
  \end{appendices}
\end{document}

答案2

您需要弹出您需要知道数量的页面,这是通过设置savepageafter的值来完成的\cleardoublepage

我还建议不要使用\arabic{page}\thesavepage,而是\value{page}使用和\value{savepage}

另外,最好使用抽象命令,避免在文档主体中使用冗长的代码。这样很容易修补appendices以完成必要的工作。因此主体中的代码更加简洁。

\documentclass[a4paper,12pt,oneside]{report}
\usepackage[toc,page]{appendix}
\usepackage{etoolbox}

\usepackage{lipsum} % for context

\newcounter{savepage}
% when appendices starts we need to reset the page number
\pretocmd{\appendices}
  {\cleardoublepage\pagenumbering{Roman}\setcounter{page}{\value{savepage}}}
  {}{}
% before the appendices we need to setup the toc
\apptocmd{\appendices}
  {%
   \addtocontents{toc}{\string\setcounter{tocdepth}{1}}%
   \addtocontents{toc}{%
     \begingroup
     \let\string\l@chapter\string\l@section
     \let\string\l@section\string\l@subsection
   }%
  }
  {}{}
% when the appendices end we need to end the group
\pretocmd{\endappendices}{\addtocontents{toc}{\endgroup}}{}{}

% front matter with Roman numbers
\newcommand{\frontmatter}{%
  \cleardoublepage\pagenumbering{Roman}\pagestyle{plain}%
}
% main matter with arabic numbers (but save the page number up to here)
\newcommand{\mainmatter}{%
  \cleardoublepage
  \setcounter{savepage}{\value{page}}%
  \pagenumbering{arabic}%
  \pagestyle{headings}% or whatever you like
}

\begin{document}

\frontmatter

\tableofcontents

\chapter*{Introduction}
\addcontentsline{toc}{chapter}{Introduction}

\lipsum

\mainmatter

\chapter{First}

\lipsum

\chapter{Conclusion and Outlook}\label{ch_conclusion}

\begin{appendices}

\chapter{First appendix}

\lipsum

\section{First section}

\lipsum

\chapter{Second appendix}

\lipsum

\end{appendices}

\end{document}

在此处输入图片描述

相关内容