2

The MWE demonstrates that the appendix number is 1 instead of A when using the combine class. Both imported documents have an appendix.

\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}
  • Maybe I misunderstood your problem, but it looks fine to me. See here. So, the first appendix has title "A An appendix" and the second one has the title "A Appendix for second article". How do you want it to be? – Vedran Šego Jun 19 '13 at 20:53
  • @VedranŠego; It gave me 1 Appendix for second article as well. However, I've provided a fix for this as an answer. Its strange though that you don't have the problem. – Mythio Jun 19 '13 at 20:55
  • I use texlive svn26509.1.20120824_r27513 on Fedora 17. Maybe that has something to do with it. – Vedran Šego Jun 19 '13 at 20:57
  • Could be, i use winedt myself. – Mythio Jun 19 '13 at 20:59
0
+50

The problem here is caused by the use of the article class in the files you are importing. In particular, an article class does not have chapters. The \appendix command numbers appendix chapters/sections in the format A.1 and similar. However, because you are using the article class, only the section number is shown.

To solve this, you have to renew the numbering to use a format of A.A, of which only the A will be shown. This can be done with the command:

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

The complete code would be:

\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}

The complete result is to big to show here, but the second chapter for instance would look like:

enter image description here

  • Thank you for the responses. You will notice in my code that I need to redefine a number of things; I do not understand why. The combine class should format each article as a stand alone article, and then revert to the book formatting until the process encounters the next article. Note: I had to reset the counters for \newtheorem environments. – Tom Price Jun 19 '13 at 21:29
  • It is doing that, but its using the article formatting for the articles it encounters. The problem is that the counters are affected by the book formatting. I.e. the section counter in the articles suddenly includes a chapter number, because the book format has chapters. This is expected behavior, but can easily be fixed in the way you did. Essentially, its the same problem as the one with the appendix, it only requires a different fix. Does the solution fix your problem? – Mythio Jun 19 '13 at 21:41
  • The manual for combine states that, "Sectioning, cross-referencing, bibliographies, etc., are local within each im- ported document." I played with the code some and found some interesting things. I removed the code that begins with \@ifclassloaded{combine}... as well as the code that redefines section and appendix numbering. The code now formats all numbers correctly. I put the code \@ifclassloaded{combine}... back in (this code solves another problem) and the file still formats correctly. – Tom Price Jun 19 '13 at 22:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.