将“附录计数器”从 \alph 更改为 \arabic

将“附录计数器”从 \alph 更改为 \arabic

我试图将 \begin{appendices} 中的“章节编号”设置为数字而不是字母。

由于我需要 2 个附录章节,一个名为附录,一个名为“Bilag”,其中附录必须带有字母,而 bilag 必须带有数字,所以我创建了一个应该能够执行此操作的新环境,但我似乎无法找出正确的命令

%Bilag
\newenvironment{Bilag}[1]{
%Reset Appendix counter, and making it into numbers
\makeatletter
\setcounter{@ppsaveapp}{0}

\renewcommand{\the@apps}{\arabic{@apps}} %This is the one that is supposed to work?

\makeatother

%Choosing the name of the new environment and adding it
\renewcommand\appendixtocname{Bilag}
  \renewcommand\appendixname{Bilag}
  \renewcommand\appendixpagename{Bilag}
\begin{appendices}#1}
{\end{appendices}}

答案1

我认为您的代码无法正常工作的主要原因是您使用了错误的计数器。计数器@pps不计算附录章节/节,而是appendices计算环境。用于对单个附录章节/节进行编号的计数器是 或chaptersection具体取决于您的文档类别。

因为appendices环境重新定义了\thechapter\thesection,所以您还应该重新定义这些宏 \begin{appendices}

我认为下面的代码可能符合您的要求。如果您正在使用类,article则应将chapter下面的所有实例替换为section

\documentclass{report}

\usepackage[toc,page]{appendix}
\renewcommand{\restoreapp}{} %% <- Start numbering at 1 in every 'appendices'

% \usepackage[danish]{babel} %% <- Uncomment if you are using babel
% \addto\captionsdanish{ %% <- Uncomment if you are using babel
  \renewcommand\appendixname{Appendiks}
  \renewcommand\appendixtocname{Appendikser}
  \renewcommand\appendixpagename{Appendikser}
% } %% <- Uncomment if you are using babel

\newenvironment{bilag}{
  \renewcommand\appendixname{Bilag}
  \renewcommand\appendixtocname{Bilag}
  \renewcommand\appendixpagename{Bilag}
  \appendices %% <- would be called as part of \begin{appendices}
  % \setcounter{chapter}{0} %% <- Not needed if you redefine \restoreapp above
  \renewcommand\thechapter{\arabic{chapter}} %% <- Should come AFTER \appendices
}{
  \endappendices %% <- would be called as part of \end{appendices}
}

\begin{document}

\tableofcontents

\chapter{First chapter}
\section{A section}
\chapter{Second chapter}
\section{A section}

\begin{appendices}
\chapter{First appendix}
\section{A section}
\chapter{Second appendix}
\section{A section}
\end{appendices}

\begin{bilag}
\chapter{First bilag}
\section{A section}
\chapter{Second bilag}
\section{A section}
\end{bilag}

\end{document}

在此处输入图片描述

答案2

恐怕我不明白你想要什么,但这里有一个猜测:

\documentclass{book}
\begin{document}
\frontmatter
\tableofcontents
\chapter{Abstract}
\mainmatter
\chapter{First Chapter}
\chapter{Second Chapter}

\appendix
\chapter{Appendix}
\section{First Appendix section}
\renewcommand{\thechapter}{\arabic{chapter}}
\chapter{Bilag}
\section{First Bilag section}

\backmatter
\chapter{Final thoughts}
\end{document}

目录

相关内容