Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm writing a thesis which is an aggregate of separate articles. I have the source code for the articles and I'm using \include to include them in the main document of the thesis. So in my main.tex (thesis document), I have

\include{article1}
some pages in between the two articles
\include{article2}

The problem that I'm getting is with the Appendix sections. In article 1, I have at the end:

\appendix
\numberwithin{equation}{section}
\section{Coefficients}\label{sec:Coeffic}
\subsection{Good coefficients}
then comes the first line of appendix

This gives in article 1 (when compiled separately with the article class):

A. Coefficients

A.1. Good coefficients

and equation numbers in the Appendix A as (A.1), (A.2)

which is ok and what is expected.

When I put article 1 within main.tex, I use \include command. Also, I removed the document class for article 1 and put \chapter instead.

But when I compile main.tex (the thesis document), I get the appendix sections as:

.1 Coefficients

.1.1 Good coefficients

and the equation numbers in the appendix A as (.1.1), (.1.2) etc

My article 1 is treated as a chapter in the main thesis document (main.tex) and the title and section numbers, equation numbers are preceded by A in main.tex. This is what I want.

Maybe it would be ok to get the appendix in my main.tex as

A.A. Coefficients

A.A.1 Good coefficients

and the equation numbers in the Appendix as (A.A.1), (A.A.2) etc

to denote that it refers to appendix A of paper A. First A is for the first article and second A is for first appendix. How to get this?

share|improve this question
    
What document class are you using? –  Seamus Oct 23 '10 at 12:42
    
Thanks. I'm using book for main.tex . I don't have any class for article 1. I start it with \chapter{title of article} –  yCalleecharan Oct 23 '10 at 12:47
1  
I think the problem is that \appendix typesets the appendix title with \section* so it doesn't get a number. Maybe using \begin{appendix} and `\end{appendix} would work? otherwise, you'll have to redfine the section command yourself. –  Seamus Oct 23 '10 at 15:04

1 Answer 1

up vote 9 down vote accepted

Preliminary remark: If an article includes an appendix (which is numbered as section A, subsection A.1, ...), and the article as a whole becomes chapter 1 of a book, the appendix in fact becomes a "subappendix" (which should be numbered as section 1.A, subsection 1.A.1, ...).

The \appendix command is defined by the document class - basically, it resets the counter of the "top section" level (\chapter in book, \section in article) and switches to Alphabetic numbering. So an \appendix command that is part of an "included" file will produce wrong results - it will redefine chapters instead of sections and in the process interfere with the numbering of subsequent chapters.

Solution: Change the definition of \appendix as to produce the desired formatting of "subappendices". (This way, you don't have to change your "included" files.) Keep the redefinition inside a group in order to allow for (main) appendix chapters.

\documentclass{book}

\usepackage{amsmath}

\usepackage{filecontents}

\begin{filecontents}{article1}
\section{foo}

Some text.

\appendix
\numberwithin{equation}{section}

\section{Coefficients}

\subsection{Good coefficients}

The first line of the appendix to article1.

\begin{equation}
a^2 + b^2 = c^2
\end{equation}
\end{filecontents}

\begin{document}

\begingroup

\renewcommand{\appendix}{%
  \par
  \setcounter{section}{0}%
  \renewcommand{\thesection}{\thechapter.\Alph{section}}%
}

\chapter{Title of article1}

\input{article1}

\endgroup

\appendix

\chapter{Title of (main) appendix}

Some text.

\end{document}

P.S.: I'd rather use \input instead of \include - you probably don't want a page break after the chapter title.

share|improve this answer
    
Thanks. The problem that I see with your method is that I'll have to include the text of article 1 in main.tex and the latter can become too lengthy if I have several articles. Am I understanding right here that with your method I can't have a separate file article1.tex? Please let me know. –  yCalleecharan Oct 23 '10 at 16:56
    
@yCalleecharan: You CAN have separate files article1.tex, ... - I only used the filecontents package (which actually produces the file "article1") in order to produce a working minimal example (which compiles after copying and pasting the code). –  lockstep Oct 23 '10 at 17:02
    
Where did you get that idea? The important part of the solution is after the \begin{document} in Lockstep's answer. The part before is actually so the answer will compile. –  Willie Wong Oct 23 '10 at 17:02
    
@lockstep: it seems that filecontents will need to be explained, along with lipsum and friends when an answer is written... –  Willie Wong Oct 23 '10 at 17:03
1  
@Willie Wong: In the LateX section of the (German-speaking) forum mrunix.de, there`s a topped thread about "error diagnostics" that, among other things, tells you everything about filecontents & Co. Perhaps we need something similar for tex.stackexchange. –  lockstep Oct 23 '10 at 17:09

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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