合并类的附录编号不起作用

合并类的附录编号不起作用

MWE 演示了使用组合类时附录编号为 1 而不是 A。两个导入的文档都有附录。

\documentclass[book]{combine}
\usepackage{amsmath,amssymb,amsfonts,amsthm,times}
\usepackage{filecontents}
\usepackage{appendix}
\usepackage{blindtext}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Prints section numbers without leading 0.
\makeatletter
\let\oldimport\import
\renewcommand*{\import}{
    \setcounter{section}{0}\renewcommand*\thesection{\arabic{section}}
    \setcounter{subsection}{0}\renewcommand*\thesubsection{\thesection.\arabic{subsection}}
    \oldimport}
\makeatother
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\makeatletter
\begin{filecontents*}{inputDoc1a.tex}
\documentclass{article}
\usepackage{amsmath,amssymb,amsfonts,amsthm,times}
\usepackage{appendix}
\usepackage{blindtext}
\makeatletter
\@ifclassloaded{combine}
  {\let\@begindocumenthook\@empty
    }
  {}
\makeatother
\begin{document}
\title{First article}
\author{Author of first article}
\maketitle
\section{first section}
This solves a problem.\index{problem}
\blindtext[1]
\section{Second section}
\blindtext[1-2]
\appendix
\section{An appendix}
\blindtext[1]
\end{document}
\end{filecontents*}

\begin{filecontents*}{inputDoc2.tex}
\documentclass{article}
\@ifclassloaded{combine}
  {\let\@begindocumenthook\@empty
    }
  {}
\makeatother
\begin{document}
\title{Second article}
\author{Author of second article}
\maketitle
\section{Section of second article}
\blindtext[1]
\appendix
\section{Appendix for second article}
\blindtext[2]
\end{document}
\end{filecontents*}

% The main document
\begin{document}
\title{The collection}
\author{A. N. Editor}
\date{\today}
\maketitle

\chapter{First chapter}
\section{Introduction}
\ldots
\begin{papers}[]
    \coltoctitle{First article}\label{coltitle}
    \coltocauthor{Author of first article}
    \import{inputDoc1a}
\end{papers}

\chapter{Second chapter}
\section{Introduction}
\ldots
\index{some dots}
\begin{papers}[]
    \coltoctitle{Third article}
    \coltocauthor{Author of third article}
    \import{inputDoc2}
\end{papers}
\end{document}

答案1

此处的问题是由您导入的文件中类的使用引起的article。具体来说,article类没有章节。该\appendix命令以类似格式对附录章节/节进行编号A.1。但是,由于您使用的是article类,因此仅显示节号。

为了解决这个问题,您必须更新编号以使用 格式A.A,其中只A显示 。这可以使用以下命令完成:

\renewcommand{\thesection}{\Alph{section}}

完整的代码如下:

\documentclass[book]{combine}
\usepackage{amsmath,amssymb,amsfonts,amsthm,times}
\usepackage{filecontents}
\usepackage{appendix}
\usepackage{blindtext}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Prints section numbers without leading 0.
\makeatletter
\let\oldimport\import
\renewcommand*{\import}{
    \setcounter{section}{0}\renewcommand*\thesection{\arabic{section}}
    \setcounter{subsection}{0}\renewcommand*\thesubsection{\thesection.\arabic{subsection}}
    \oldimport}
\makeatother
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\makeatletter
\begin{filecontents*}{inputDoc1a.tex}
\documentclass{article}
\usepackage{amsmath,amssymb,amsfonts,amsthm,times}
\usepackage{appendix}
\usepackage{blindtext}
\makeatletter
\@ifclassloaded{combine}
  {\let\@begindocumenthook\@empty
    }
  {}
\makeatother
\begin{document}
\title{First article}
\author{Author of first article}
\maketitle
\section{first section}
This solves a problem.\index{problem}
\blindtext[1]
\section{Second section}
\blindtext[1-2]
\appendix
\renewcommand{\thesection}{\Alph{section}}
\section{An appendix}
\blindtext[1]
\end{document}
\end{filecontents*}

\begin{filecontents*}{inputDoc2.tex}
\documentclass{article}
\@ifclassloaded{combine}
  {\let\@begindocumenthook\@empty
    }
  {}
\makeatother
\begin{document}
\title{Second article}
\author{Author of second article}
\maketitle
\section{Section of second article}
\blindtext[1]
\appendix
\renewcommand{\thesection}{\Alph{section}}
\section{Appendix for second article}
\blindtext[2]
\end{document}
\end{filecontents*}

% The main document
\begin{document}
\title{The collection}
\author{A. N. Editor}
\date{\today}
\maketitle

\chapter{First chapter}
\section{Introduction}
\ldots
\begin{papers}[]
    \coltoctitle{First article}\label{coltitle}
    \coltocauthor{Author of first article}
    \import{inputDoc1a}
\end{papers}

\chapter{Second chapter}
\section{Introduction}
\ldots
\index{some dots}
\begin{papers}[]
    \coltoctitle{Third article}
    \coltocauthor{Author of third article}
    \import{inputDoc2}
\end{papers}
\end{document}

完整的结果太大,无法在这里展示,但例如第二章看起来像这样:

在此处输入图片描述

相关内容