Document ClassesAppendix Numbering Issues

Information and discussion about specific document classes and how to create your own document classes.
Post Reply
sw3quant
Posts: 76
Joined: Tue Nov 02, 2010 11:40 pm

Appendix Numbering Issues

Post by sw3quant »

Hello.

I am new to Latex. I am using MikTex 2.8, WinEdt 6, JABREF 2.6 and Windows Vista. I am creating PDFs, working from a template:
http://www-h.eng.cam.ac.uk/help/tpl/tex ... PSnPDF.zip

The template is a bit complex, but in outline I have chapters and appendices as can be seen here:

Code: Select all

\include{Dedication/dedication}
\include{Acknowledgement/acknowledgement}
\include{Abstract/abstract}
\tableofcontents
\listoffigures
\listoftables
\printnomenclature  %% Print the nomenclature
\addcontentsline{toc}{chapter}{Nomenclature}
\mainmatter % book mode only
\include{Introduction/introduction}
\include{Chapter1/chapter1}
\include{Chapter2/chapter2}
\include{Chapter3/chapter3}
\include{Chapter4/chapter4}
\include{Chapter5/chapter5}
\include{Chapter6/chapter6}
\include{Chapter7/chapter7}
\include{Conclusions/conclusions}
\backmatter % book mode only
\appendix
\include{Appendix1/appendix1}
\include{Appendix2/appendix2}
\include{Appendix3/appendix3}
each appendix tex file looks like:

Code: Select all

\begin{subappendices}
\chapter{Appendix A: stuff}
\section{Introduction}
Blah
\section{First Paragraph}
And now I begin my first chapter here ...
\section{Conclusions}
blah
\end{subappendices}
When the PDF compiles, in the contents the chapters are nicely laid out: Chapter 1 (with 1.1, 1.2...) and then Chapter 2 (2.1,2.2...) and so on. When it gets to the appendices the numbering breaks


Appendix A: stuff 92
.A Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
.B Data Quality . . . . . . . . . . . . . . . . . . 94
.C Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94

Appendix B: Engine 103
.A Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
.B feedback . . . . . . . . . . . . . . . . . . . . 103
.C Cost . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
.C.1 Cost Data. . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
.C.2 Cost Models . . . . . . . . . . . . . . . . . . . . . . . 103

and so on. What I would like to see is A1, A2,A3.... for Appendix A. And then B1, B2.... for appendix B and so on.

I have read the similiar entries on here that have similiar problems but have not been able to fix it. Any help very gratefully recieved.

Many Thanks!

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Appendix Numbering Issues

Post by frabjous »

When I try to change the appendix1.tex file in the template provided to something like what you put, I get an error about the subappendices environment being undefined. I think you must also be loading the appendix package somewhere; but that's the kind of thing we need to know.

Anyway, I don't think you should be using the subappendices environment anyway. That environment in the appendix package would only be appropriate if you wanted each "\section" command to introduce a different lettered appendix; but you seem to want each appendix to go with "\chapter".

Moreover, while I'm not sure it's the best practice, your sample appendix made it seem as if the "lettering" of these appendices was being done manually rather than automatically. If you wanted to do it that way (which is probably OK if you don't have a small number of appendices). But then you'll probably need to manually tell it for each one what to prefix the section numbers with as well.

So one option would be to do the following:

1. Remove the \begin{subappendices} and \end{subappendices} in each appendix. You could leave them otherwise unchanged.

2. Before inputting each appendix, manually renew the section numbering scheme, as follows:

Code: Select all

\backmatter % book mode only
\appendix
\renewcommand{\thesection}{A.\arabic{section}}
\include{Appendix1/appendix1}
\renewcommand{\thesection}{B.\arabic{section}}
\include{Appendix2/appendix2}
That'll make them A.1, A.2, etc. If you want, you could remove the period {A\arabix{section}} if you wanted A1, A2, A3 with no period in between. That seems to work with that template.

There should be ways of getting all the numbering to be automatic, but the template does not seem set up for that as is.
sw3quant
Posts: 76
Joined: Tue Nov 02, 2010 11:40 pm

Re: Appendix Numbering Issues

Post by sw3quant »

Many thanks for your reply.

I am unclear on why you are getting an error, but I have made a few changes to the cls file over the version on the web. I have attached the cls file.

You say "your sample appendix made it seem as if the "lettering" of these appendices was being done manually rather than automatically." This is not the case: it was done by latex. I have done no manual numbering or lettering.

I have quite large appendices with lots of sections and subsections and hence I really cant do this manually. I need a way for Latex to do it.

I tried as you suggested. I did the following:
1. I removed the \begin{subappendices} and \end{subappendices} in each appendix and
2. I commeneted out \appendix on the front tex file
and
3. I added \renewcommand{\thesection} {A.\arabic{section}} before each include on the front tex file
and
4. I commeneted out %\begin{appendices} and %\end{appendices} in the appendices.

The result is not quite right but closer than before. Thank you!

In the contents table at the front the following now appears:
Appendix A: Data 91
A.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
A.2 Data Quality . . . . . . . . . . . . . . . . . . 93
A.3 Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93

Appendix B: Engine 102
B.13 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
B.14 feedback . . . . . . . . . . . . . . . . . . . . 102
B.15 factors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102

What isn't correct is that I want B to start at B1 and C at C1 and so on. Not carrying off from the last chapter.

Any ideas on how this could be achieved?

Many Thanks
Attachments
CUEDthesisPSnPDF.cls
(11.93 KiB) Downloaded 564 times
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Appendix Numbering Issues

Post by frabjous »

sw3quant wrote:Many thanks for your reply.
I am unclear on why you are getting an error, but I have made a few changes to the cls file over the version on the web. I have attached the cls file.
If you're new at LaTeX, you should not be editing cls files! If you're just adding packages, you can do that in the preamble of your .tex file.
You say "your sample appendix made it seem as if the "lettering" of these appendices was being done manually rather than automatically." This is not the case: it was done by latex. I have done no manual numbering or lettering.
In your previous post you have the line:

Code: Select all

\chapter{Appendix A: stuff}
I don't see how that "A" could have been inserted in your code by LaTeX. That is lettering "by hand". If you're appendix does not look like what you reported, then tell us what it does look like.

Code: Select all

I have quite large appendices with lots of sections and subsections and hence I really cant do this manually. I need a way for Latex to do it.
I wasn't talking about numbering the sections, but lettering the appendices. It's fine to letter the appendices manually and number the sections automatically. If you want both numbering and lettering to happen automatically, then some other changes will be necessary.
2. I commeneted out \appendix on the front tex file
and
I didn't tell you to do that. I'm not sure what effect that would have, but you should probably put it back in.
4. I commeneted out %\begin{appendices} and %\end{appendices} in the appendices.
There is no hint of any such thing in the sample appendix you posted earlier, so I cannot guess what effect this would have.

You can manually reset the section counter:

Code: Select all

\setcounter{section}{0}
when needed. (E.g., put that right before or after the \renewcommand line...)

There would be ways of automating all this, but with the behemoth of a template you've got there, I'm a bit afraid to try.
User avatar
bev
Posts: 20
Joined: Wed Nov 10, 2010 10:02 am

Appendix Numbering Issues

Post by bev »

I didn't bother to check this in the CUEDthesis class you are using, but that class is based on the `book' class, and the \appendix isn't redefined in it, so this should work (it works in the book class).

Code: Select all

\appendix
\makeatletter
\renewcommand{\thesection}{\thechapter\@arabic\c@section}
\renewcommand{\thesubsection}{\thesection\@arabic\c@section}
\renewcommand{\thesubsubsection}{\thesubsection\@arabic\c@section}
\makeatother
This is kind of a kludge, the correct way is to use an \ifthenelse statement with \equal{\@chapapp}{\appendixname} or something as the first arg, but I don't have time to pursue it to that extent. As I said, the above works in my setup.

I'm attaching a pdf of a test file I made. And here's the code for the test file (extraneous text slightly reduced:

Code: Select all

\documentclass{book}
\usepackage{ifthen}
\author{B. Lah}
\title{The Tao of Blah}
\begin{document}
\maketitle
\tableofcontents

\chapter{One}
Lorem ipsum dolor sit amet, consectetur adipiscing elit.

\chapter{Two}
 In ante ipsum, iaculis quis, sollicitudin non, sagittis ut, tortor. 

\appendix
\makeatletter
\renewcommand{\thesection}{\thechapter\@arabic\c@section}
\renewcommand{\thesubsection}{\thesection\@arabic\c@section}
\renewcommand{\thesubsubsection}{\thesubsection\@arabic\c@section}
\makeatother

\chapter{Things You Should Know}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent
tortor.

\section{History}
Lorem ipsum dolor sit amet, consectetur adipiscing elit.

\section{Mathematics}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. 

\chapter{Other Stuff}
 In ante ipsum, iaculis quis, sollicitudin non, sagittis ut, tortor. Etiam rutrum.

\section{Baking}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent
tortor. Suspendisse scelerisque mi non risus. 

\section{Barbecue}
Lorem ipsum dolor sit amet, consectetur adipiscing elit.

\end{document}

Attachments
tstbook.pdf
(49.08 KiB) Downloaded 664 times
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Appendix Numbering Issues

Post by frabjous »

The CUEDthesis class doesn't seem to work quite the same as the book class.

I'm curious, however, what the advantages would be of:

Code: Select all

\appendix
\makeatletter
\renewcommand{\thesection}{\thechapter\@arabic\c@section}
\renewcommand{\thesubsection}{\thesection\@arabic\c@section}
\renewcommand{\thesubsubsection}{\thesubsection\@arabic\c@section}
\makeatother
over the simpler:

Code: Select all

\appendix
\renewcommand{\thesection}{\thechapter.\arabic{section}}
\renewcommand{\thesubsection}{\thesection.\arabic{subsection}}
\renewcommand{\thesubsubsection}{\thesubsection.\arabic{subsubsection}}
which seems to work fine in the book class.
User avatar
bev
Posts: 20
Joined: Wed Nov 10, 2010 10:02 am

Appendix Numbering Issues

Post by bev »

@frabjous: 2 things:

1) you're correct, that is simpler. Thanks for pointing that out.

2) since I thought the entire point (so to speak) was to remove the `.' between the `A' and the `1' (so that it reads A1 not A.1) I'll go you one better and say that

Code: Select all

\appendix
\renewcommand{\thesection}{\thechapter\arabic{section}}
\renewcommand{\thesubsection}{\thesection\arabic{subsection}}
\renewcommand{\thesubsubsection}{\thesubsection\arabic{subsubsection}}
is the way to go in the book.cls case. I'll look into the CUEDthesis case tonight.

(on a different subject, I just finished reading John Ringo's 4 'vorpal blade' books: Into the Looking Glass, Vorpal Blade, Manxome Foe, and Claws that Catch. So I was amused by the kismetic occurrence of your name)
User avatar
bev
Posts: 20
Joined: Wed Nov 10, 2010 10:02 am

Appendix Numbering Issues

Post by bev »

OK, frabjous -

I take back my capitulation in the previous reply :-). When I checked your solution in book.cls it worked, but when I checked it in CUEDthesisPSnPDF it didn't --- but mine did! Yay for me.

So, here's the code for the working file in CUEDthesisPSnPDF.cls:

Code: Select all

\documentclass[book]{Classes/CUEDthesisPSnPDF}
\author{B. Lah}
\title{The Tao of Blah}
\degree{Doctor of Philately}
\degreedate{ASAP}
\collegeordept{Rigamarole}
\university{Whatsamatta U.}
\begin{document}
\maketitle
\tableofcontents

\chapter{One}
Lorem ipsum dolor sit amet, consectetur adipiscing elit.

\chapter{Two}
 Curabitur dui erat,ultrices id, euismod vel, adipiscing at, mauris. Donec congue dui et metus. Donec erat. Pellentesque cursus velit a velit.

\appendix
\makeatletter
\renewcommand{\thesection}{\thechapter\@arabic\c@section}
\renewcommand{\thesubsection}{\thesection\@arabic\c@section}
\renewcommand{\thesubsubsection}{\thesubsection\@arabic\c@section}
\makeatother

\chapter{Things You Should Know}
 Duis vitae ligula eget nunc fermentum malesuada. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.

\section{History}
Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.

\section{Mathematics}
 Duis vitae ligula eget nunc fermentum malesuada. Class aptent taciti sociosqu ad litoratorquent per conubia nostra, per inceptos himenaeos.

\chapter{Other Stuff}
 In ante ipsum, iaculis quis, sollicitudin non, sagittis ut, tortor. Etiam rutrum.

\section{Baking}
Lorem ipsum dolor sit amet, consectetur adipiscing elit.

\section{Barbecue}
Class aptent taciti sociosqu ad litora
torquent per conubia nostra, per inceptos himenaeos.

\end{document}
Oh, and I had to do a minor hack in CUEDthesisPSnPDF.cls to get it to compile (nothing to do with this issue, I just didn't have a crest to use). On line 211 I commented out the whole line:
%%{\large \vspace*{35mm} {{\@crest} \par} \vspace*{25mm}}

Anyway is this problem fixed? Seems so....
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Appendix Numbering Issues

Post by frabjous »

bev wrote:OK, frabjous -

I take back my capitulation in the previous reply :-). When I checked your solution in book.cls it worked, but when I checked it in CUEDthesisPSnPDF it didn't --- but mine did! Yay for me.
Unfortunately, you may need to take back your taking back. While it's true that your code works in the sample document you created from scratch, it does not work if you insert it into the corresponding part of the template's thesis.tex which is included in that .zip file. Indeed, the behavior there is very strange -- your code reduces the appendix sections to have numbers only and no letters. No doubt the original poster's document is more like that file. My simpler version for the book class doesn't work either. Probably with some further investigation we could figure out what's going wrong, but the template is so big, with so many files, that it's just an awful mess. Why on Earth would anyone create an 80-file template and gave it to beginning LaTeX users? It's insane. You'd need an advanced Engineering degree from Cambridge just to figure it out!

Anyway, the following does work when inserted in the appropriate place in thesis.tex:

Code: Select all

\backmatter % book mode only
\appendix
\renewcommand{\thesection}{A.\arabic{section}}
\include{Appendix1/appendix1}
\setcounter{section}{0}
\renewcommand{\thesection}{B.\arabic{section}}
\include{Appendix2/appendix2}
Of course, it would be annoying to renew the sectioning command and reset the counter with each appendix if there were a lot of appendixes, but if there are only one or two, then it seems like an easier workaround than digging around in all those files to figure out what is going on. It sounds like the original poster has long appendices with lots of sections, but only a small number of appendices, so this should be OK.
) since I thought the entire point (so to speak) was to remove the `.' between the `A' and the `1' (so that it reads A1 not A.1) I'll go you one better and say that
No, I don't think the original poster minds the '.'s. Indeed, I think it looks better with them there (though they're easily removed, as you point out). The original problem was that each section in each appendix was getting a letter rather than a number, and it was printed with the first dot on the wrong side. That was a byproduct of the \begin{subappendices} stuff. The second problem was that the section counter was not resetting. I didn't notice that problem in my first suggestion, since the template sample appendices only has sections in the first appendix, and I was testing with that.
(on a different subject, I just finished reading John Ringo's 4 'vorpal blade' books: Into the Looking Glass, Vorpal Blade, Manxome Foe, and Claws that Catch. So I was amused by the kismetic occurrence of your name)
I actually haven't read those. Are they any good? It amazes me how often you see references to Jabberwocky all over the place.
Anyway is this problem fixed? Seems so....
We'll have to wait until we hear from sw3quant.
User avatar
bev
Posts: 20
Joined: Wed Nov 10, 2010 10:02 am

Appendix Numbering Issues

Post by bev »

I found the (or maybe just a) problem. You don't need to have to reset the counters if you don't use \backmatter in thesis.tex. So, I plugged in my solution, commented out \backmatter, and it worked just like the tstbook file I posted. I changed the appendices so that there are multiple sections and subsections in them for my test.

Here's my final version:

Code: Select all

\appendix
\makeatletter
\renewcommand{\thesection}{\thechapter. \@arabic\c@section}
\renewcommand{\thesubsection}{\thesection. \@arabic\c@section}
\renewcommand{\thesubsubsection}{\thesubsection. \@arabic\c@section}
\makeatother

% and then just include however many appendices you have

\include{Appendix1/appendix1}
\include{Appendix2/appendix2}
Yours works too, but, as you pointed out, having to renew for each new appendix section is not optimal. Also (a nitpick) In mine the counters make all the labels. You don't have to specify `A.', `B.' etc. So the guy got 2 solutions for the price of one. Lucky man.

Moving on...

\backmatter is not defined in CUEDthesisPSnPDF so it's using the def from book.cls. Here's the def from book.cls:

Code: Select all

\newcommand\backmatter{%
  \if@openright
    \cleardoublepage
  \else
    \clearpage
  \fi
  \@mainmatterfalse}
You can see that it really doesn't do much. I think it's one of those things where you can use it to change parts of the doc around if you want, but you have to specify or it does nothing. So there's really no point to using \backmatter, and it screws the counters up (cause of turning off mainmatter I think).


I agree that there's way too much info in the CUED package. Also, what little I've done poking around makes me wonder. Does he really need 3 different ways to do the abstract, all with their own environment? (he does use emacs tho, so he's got something on the ball...) It seems like most of the thrust is to make sure that both pdflatex and latex will work using his class, which is ok. For myself, I'm wary of the hyperref package cause it tends to mess up stuff I want to do much of the time.

The John Ringo books were pretty good. If you like middle-period Heinlein, you'll probably like Ringo. He does the military space thing even better than RAH, and in places has the action style of ee doc smith (the Lensman). It's nice to see that old-style SF is still being done (as opposed to dystopian cyberpunk knock-offs).

And Ringo can be pretty funny too.
Post Reply