[plug] LyX/LaTeX questions

Greg Gamble gregg at maths.uwa.edu.au
Wed Nov 3 11:57:31 WST 1999


Hi Christian,

> Firstly I'd like to customise the page numbering in my appendices.
> For example, Appendix A pages I'd like to be numbered: A-1, A-2, A-3 and
> so on as appropriate for the other appendices too.  Is that possible?  If
> anyone has any suggestions I'd really like to know. :-)

There's almost certainly a package that will do this ... but after a 
(very) quick perusal of the docs on my teTeX system I didn't see it
... here's some code that will do the trick:

\makeatletter
\let\normalappendix\appendix
\let\normal at chapter\@chapter
\let\normal at schapter\@schapter
\newif\ifappendix
\def\appextra{\ifappendix \setcounter{page}{1} \fi}
\renewcommand{\appendix}
    {\normalappendix\appendixtrue
     \renewcommand{\thepage}{\thechapter-\@arabic\c at page}}
\def\@chapter[#1]#2{\normal at chapter[#1]{#2}\appextra}
\def\@schapter#1{\normal at schapter{#1}\appextra}
\makeatother

Put this in your `preamble' i.e. between the \documentclass and
\begin{document} lines.

A few words of explanation:

  1. You will notice that three LaTeX commands have been extended,
     namely: \appendix, \@chapter and \@schapter

       \appendix  ... is issued prior to your appendices
		      to tell LaTeX that any \chapter from now on
		      is an appendix (presumably you know that)
		      The extension sets a Boolean `flag'
		      \appendixtrue and \thepage

       \@chapter,
       \@schapter ... one of these is called by LaTeX when you use
		      the \chapter command. The former is called
		      except when \chapter* (for unnumbered chapters)
                      when the latter is called. Essentially, when
		      these commands are called after the command
		      \appendix has been issued we want \chapter
		      and \chapter* to reset the page counter to 1.
		      That's what \appextra does.

  2. \thepage is the command LaTeX uses to set the page in a footer
     or header

You will notice that many of the commands have `@' symbols in them
... these tell you they are internal LaTeX commands. To make (La)TeX
treat the `@' symbol as a letter one has to issue a \makeatletter
command (which changes its character code appropriately), and then to
put things back to normal we issue a \makeatother.

(BTW LaTeX has an \@addtoreset internal which can be used to
automatically reset a counter to zero when another counter is stepped.
But that doesn't help here because the page counter needs to be reset
to 1 ... hence why it was coded as above.)

I've tested it ... and it seems to do the job. Let us know how you go.

> Also, I've noticed sometimes LaTeX hyphenates text in section titles
> etc.  Is there a way of stopping it from doing this?

As Adrian Blockley pointed out a line break (\\) will do the job ...
but if you don't want that line break to appear in your Table of
Contents, use the optional argument e.g.

\section[A long header with no line break]{A long header with\\a line break}

  Regards,
  Greg Gamble <gregg at maths.uwa.edu.au>



More information about the plug mailing list