[comp.text.tex] Forcing \addcontentsline to write to "toc" file

bed_gdg@SHSU.BITNET ("George D. Greenwade") (03/25/91)

On Fri, 22 Mar 1991 16:56:06 EST, Jon E. Ahlquist <AHLQUIST@metsat.met.fsu.edu>
submitted the following to LaTeX-help@sumex-aim.stanford.edu.  I am unable to
help Jon directly, but thought that the collective wisdom of
LaTeX-help-toughies and INFO-TeX would have an answer.  Recall that the
questioner in this case and the one in need of immediate assistance is:
                         AHLQUIST@metsat.met.fsu.edu
 
Regards,   George
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
George D. Greenwade, Ph.D.                            Bitnet:  BED_GDG@SHSU
Department of Economics and Business Analysis         THEnet: SHSU::BED_GDG
P. O. Box 2118                                        Voice: (409) 294-1266
Sam Houston State University                          FAX:   (409) 294-3612
Huntsville, TX 77341            Internet: bed_gdg%shsu.decnet@relay.the.net
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
Dear Sir/Madam:
 
I am modifying suthesis.sty to create a style for theses at Florida
State University.  Everything is fine except for one LaTeX problem.
 
My LaTeX "root" file, thesis.tex, contains the following lines
as it attempts to set up the appendix section of a thesis:
 
\addcontentsline{toc}{chapter}{Appendices}
\appendix
\include{append_a} % Include appendix A stored in append_a.tex
\clearpage
 
(The complete files thesis.tex and fsuthesis.sty are appended
at the end of this letter just in case I have omitted something
important from my example.)
Despite the fact that: \addcontentsline{toc}{chapter}{Appendices}
precedes:              \include{append_a} \clearpage
the table of contents file contains the entries in reversed order:
 
\contentsline {chapter}{\numberline {A}Reaction Rates}{9}
\contentsline {chapter}{Appendices}{9}
 
If this were only for myself, I would edit the ".toc" file
to reverse the lines, but I am trying to prepare something
that any and all graduate students at Florida State University could use.
Therefore, I would like to find a "clean" solution to the problem.
Is there a way to force the \addcontentsline
message to be written before the chapter listing for appendix A?
 
Thank you.
 
- Jon
Dr. Jon E. Ahlquist, Dept. of Meteorology B161, Florida State University
Tallahassee, FL 32306-3034
Telephone: (904) 644-1558
Internet: ahlquist@met.fsu.edu
or        ahlquist@metsat.met.fsu.edu
 
------------- Complete listing of "root" file thesis.tex -------------
 
% Example of how to use fsuthesis.sty
% It is recommended that you use this file as a model for your own
% thesis, treatise, or dissertaion.
% The present format was approved by the FSU Graduate School
% in August 1990.
% This example was created by Meade Carlson and Jon Ahlquist
% in August 1990 and was greatly modified by Jon Ahlquist, 18 March 1991.
 
\documentstyle[11pt,fixup,fsuthesis,threepart]{report}
% 11pt indicates that 11 point type will be the size of standard text.
% fixup.tex fixes a few minor bugs in LaTeX's styles.
% fsuthesis.sty defines the layout for the cover page
%    and for a few commands noted below.
% threepart.sty enables the user to define three part headers and footers.
%    It is used to place the page numbers.
 
\typeout{}
\typeout{IMPORTANT!}
\typeout{LaTeX must be run at least twice on this file}
\typeout{in order to construct the table of contents}
\typeout{and to satisfy cross-references.}
\typeout{}
 
\includeonly{%
acknowl,%
abstract,%
chap1,%
chap2,%
append_a,%
refernce,%
vita%
} %end of \includeonly
 
\input texmacro
% texmacro.tex by Jon Ahlquist contains "macros" to carry out
% several common commands, like standard Latin abbreviations
% and, for math people, partial derivatives.
 
% To simplify work with individual chapters, we \include them
% rather than \input them.  If you do not want one or more of the
% following files to be processed, place "%" before the file name
% in the list below.
% For more details, look up \includeonly in the LaTeX manual.
 
\begin{document}
 
%%%%%%%%%%%%
% Title page
%%%%%%%%%%%%
% The following information must be specified before the title
% page can be printed.
% \title and \author are standard LaTeX commands.
% \submitsemester through \degree are defined in fsuthesis.sty,
% as is the layout for the title page.
\title{A Study of Nothingness\\
       and its Relation to Something}
\author{Buckaroo Bonzai}
\doctype{Dissertation}
\submitsemester{Spring}
\submityear{1991}
\dept{Meteorology}
\college{Arts and Sciences}
\degree{Doctor of Philosophy}
 
% If you do not want a copyright statement to appear at the bottom
% of the title page, place a percent sign (%) in column 1 of:
%\copyrighttrue
% Remove "%" from column 1 of \copyrighttrue if you do want a copyright
% notice to be printed at the bottom of the title page.
 
% The following command defined in fsuthesis.sty prints the title page.
\maketitlepage
 
%%%%%%%%%%%%%%%%
% Signature page
%%%%%%%%%%%%%%%%
% You will need to edit this page to suit your own purposes.
 
\thispagestyle{empty} %Suppress page numbers on this page only.
 
The members of the Committee approve the dissertation of
Buckaroo Bonzai defended on March 18, 1991.
 
% The members of the committee need lines for signatures
% with their names and responsibilities printed underneath.
% This is done using \sigbox, which is defined in fsuthesis.sty.
% \begin{flushright} will push the signature spaces to the right side
% of the page.
\begin{flushright}
\sigbox{Werner von Braun\\Professor Co-directing Dissertation}
\sigbox{Albert Schweitzer\\Professor Co-directing Dissertation}
\sigbox{Doogie Howser\\Outside Committee Member}
\sigbox{Julius Erving\\Committee Member}
\sigbox{Henry Kissinger\\Committee Member}
\end{flushright}
\newpage
 
%%%%%%%%%%%%%%%%%%
% Acknowledgements
%%%%%%%%%%%%%%%%%%
% Create an entry in the table of contents for acknowledgements.
\addcontentsline{toc}{chapter}{Acknowledgements}
% The first line of acknowl.tex should be \chapter*{Acknowledgements}
\include{acknowl} % Include file acknowl.tex which contains acknowledgements.
\newpage
 
%%%%%%%%%%%%%%%%%%%%%%%%%
% Table of contents, etc.
%%%%%%%%%%%%%%%%%%%%%%%%%
% Print a table of contents, a list of tables, and a list of figures.
{\baselineskip=13pt %Single space the table of contents.
\tableofcontents\newpage  % Write the table of contents.
\tableoftables\newpage    % Put "%" in column 1 to omit a list of tables.
\tableoffigures\newpage   % Put "%" in column 1 to omit a list of figures.
} %end of \baselineskip=13pt for single spacing.
 
% \tableoftables and \tableoffigures are defined in fsuthesis.sty.
% They make use of LaTeX's \listoftables and \listoftables commands.
 
% An entry for the table of contents will be created automatically if
% one uses a \chapter command.  No entry is created automatically when
% the \chapter* command is used.  That is why \addcontentsline is used
% for the acknowledgements, abstract, references, and vita.
 
%%%%%%%%%%
% Abstract
%%%%%%%%%%
% Create an entry in the table of contents for the abstract.
\addcontentsline{toc}{chapter}{Abstract}
% The first line of abstract.tex should be \chapter*{abstract}
% and the last line should be \endinput
\include{abstract} \newpage
 
 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Do set-up for the chapters.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
% Number the pages with Arabic (standard) numbers.
\pagenumbering{arabic}
 
% The first page of each chapter will have a page number centered
% at the bottom of the page.
% Subsequent pages in a chapter will be numbered in the center at the top
% of the page.  This is done using file threepar.sty.
% The next line tells threepar.sty to place the page number
% centered in the header and to leave the center of the footer blank
% (after the first page of each chapter.)
\chead{\thepage} \cfoot{}
 
 
%%%%%%%%
% Include the chapters.
%%%%%%%%
% The first line of each chapter file should be
% \chapter{Name of the chapter.}
% To be safe, the last line of each chapter should be \endinput
% Although \endinput is not necessary with every word processor,
% some word processors like WordStar store "garbage" characters
% at the end of files.  \endinput will prevent any trailing garbage
% characters from affecting your document.
\include{chap1} \clearpage % Include chapter 1.
\include{chap2} \clearpage % Include chapter 2.
% Similar \include and \clearpage commands are needed
% for subsequent chapters.
 
%%%%%%%%%%%%
% Appendices
%%%%%%%%%%%%
% If you do not have appendices, remove "%" from column 1 of the
% "\comment{" line and remove "%" before the right curly bracket, },
% at the end of this appendix section.
% \comment{
% Add a line to the table of contents that marks the beginning
% of the appendix listings.
\addcontentsline{toc}{chapter}{Appendices}
 
\appendix %This tells LaTeX that subsequent "chapters" are appendices.
\include{append_a} \clearpage % Include appendix A.
% As with chapters, the first line of an appendix file should be
% \chapter{Name of the appendix}
% and the last line should be \endinput.
% Similar \include and \clearpage commands are needed
% for subsequent appendices.
 
%} %Remove "%" from the beginning of this line if you do not have appendices.
 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Reference list and/or bibliography
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Create an entry in the table of contents for references.
\addcontentsline{toc}{chapter}{References}
 
% Input journals.tex which contains abbreviations
% for journals and which defines \cit{}, which allows for "hang indented"
% citations.  The journal abbreviations are for meteorology,
% but they give the sense of how to create abbreviations for
% journals in other fields.
\input journals
 
% Include refernce.tex which holds the reference list and/or bibliography.
% The first line of refernce.tex should be \chapter*{References}
% The last line should be \endinput
\include{refernce}
 
%%%%%%%%%%%%
% Brief vita
%%%%%%%%%%%%
% Create an entry in the table of contents for the vita.
\addcontentsline{toc}{chapter}{Vita}
 
% The first line of vita.tex should be \chapter*{Vita}
% vita.tex should contain a brief vita of the author.
\include{vita}
 
\end{document}
 
------------------ Complete listing of fsuthesis.sty ------------
 
% Florida State University M.S. and Ph.D. thesis, treatise,
% and dissertation style.
% See the file thesis.tex for an example of how to use this style.
%
% History of this file: fsuthesis.sty is modified from suthesis.doc,
% which is the Stanford University Ph.D. thesis style.
% suthesis.doc can be found in the "inputs" directory of most
% TeX systems.
% Limitations of MS-DOS file names mean that this file will be
% named fsuthesi.sty on MS-DOS computers, but you should always
% cite this file as fsuthesis.sty for consistency.
% MS-DOS computers will take fsuthesi.sty if you reference fsuthesis.sty,
% so there is no problem.
%
% Modifications by Dr. Jon Ahlquist, Dept. of Meteorology, 19 June 1990,
% with considerable help from Meade Carlson.
% Extensive editing by Jon Ahlquist in March 1991.
%
\long\def\comment#1{}
\comment{
Documentation for fsuthesis.sty:
 
This style file modifies LaTeX's standard report style
to follow the Florida State University Office of Graduate Studies
"Guidelines and Requirements for Thesis, Treatise, and Dissertation
Writers."  It sets the margins, interline spacing, the figure and
table numbering style, and disallows page breaks at hyphens.
 
To use fsuthesis.sty, insert it as one of the documentstyle options, i.e.
\documentstyle[11pt,fixup,fsuthesis]{report}
11 point type, as indicated by 11pt, is recommended.
No spaces are allowed anywhere between the left and right
square brackets: [11pt,etc.]
 
The following commands control what appears on the title page.
You must substitute the actual title for "thesis title,"
your name for "author's name," etc.
\title{thesis title}
\author{author's name}
\dept{author's department}
\college{college of which the department is a member}
\submitsemester{Fall, Spring, or Summer}
\submityear{1991, 1992, or whatever}
\copyrighttrue or \copyrightfalse
   - produce or don't produce a copyright page.
     If neither statement is present, no copyright notice will appear.
 
Text is double spaced except in the figure and table environments
where normal spacing is used.
That can be changed by the command:
\renewcommand{\baselinestretch}{2.0}
(or whatever you want instead of 2.0)
Unfortunately, that command probably will not take effect unless it comes
before the \begin{document} or after something like \small \normalsize.
 
See the file thesis.tex for an example of how to use this style.
} %end of long \comment
 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
% The average user can ignore the rest of this file.
% From here to the end are the nitty-gritty definitions that
% define the commands mentioned above.  This is not for the
% naive or innocent.
 
% We need 1" margins except on the binding edge, where it is 1 1/2"
\oddsidemargin 0.5in \evensidemargin 0in
\marginparwidth 40pt \marginparsep 10pt
\topmargin 0pt \headsep .5in
\textheight 8.1in \textwidth 6in
 
% Disallow page breaks at hyphens.  This will give some underfull vbox's,
% so an alternative is to use \brokenpenalty=100 and manually search
% for and fix such page breaks.
\brokenpenalty=10000
 
% Double space the text, which means twice the normal
% baseline-to-baseline skip.
\renewcommand{\baselinestretch}{2.0}
 
% Figures and tables are to be numbered sequentially throughout the
% thesis, rather than within chapters; for style consistency, do
% equations the same.  The following \def of \cl@chapter is a kludge:
% really there should be a \removefromreset, to stop figure numbers, etc.,
% from being reset at chapter beginnings
\def\cl@chapter{\@elt{section}\@elt{footnote}}
\def\thefigure{\@arabic\c@figure}
\def\thetable{\@arabic\c@table}
\def\theequation{\arabic{equation}}
 
% Redefine the macro used for floats (including figures and tables)
% so that single spacing is used.
% (Note \def\figure{\@float{figure}set single spacing} doesn't work
%  because figure has an optional argument)
\def\@xfloat#1[#2]{\ifhmode \@bsphack\@floatpenalty -\@Mii\else
   \@floatpenalty-\@Miii\fi\def\@captype{#1}\ifinner
      \@parmoderr\@floatpenalty\z@
    \else\@next\@currbox\@freelist{\@tempcnta\csname ftype@#1\endcsname
       \multiply\@tempcnta\@xxxii\advance\@tempcnta\sixt@@n
       \@tfor \@tempa :=#2\do
                        {\if\@tempa h\advance\@tempcnta \@ne\fi
                         \if\@tempa t\advance\@tempcnta \tw@\fi
                         \if\@tempa b\advance\@tempcnta 4\relax\fi
                         \if\@tempa p\advance\@tempcnta 8\relax\fi
         }\global\count\@currbox\@tempcnta}\@fltovf\fi
    \global\setbox\@currbox\vbox\bgroup
    \def\baselinestretch{1}\@normalsize
    \boxmaxdepth\z@
    \hsize\columnwidth \@parboxrestore}
 
% Redefine the macro used for footnotes to use single spacing
\long\def\@footnotetext#1{\insert\footins{\def\baselinestretch{1}\footnotesize
    \interlinepenalty\interfootnotelinepenalty
    \splittopskip\footnotesep
    \splitmaxdepth \dp\strutbox \floatingpenalty \@MM
    \hsize\columnwidth \@parboxrestore
   \edef\@currentlabel{\csname p@footnote\endcsname\@thefnmark}\@makefntext
    {\rule{\z@}{\footnotesep}\ignorespaces
      #1\strut}}}
 
% \author and \title are defined in LaTeX's "report" style.
% Here are the rest of the macros for the title page.
\def\dept#1{\gdef\@dept{#1}}
\def\college#1{\gdef\@college{#1}}    % Arts and Sciences, Law, etc.
\def\doctype#1{\gdef\@doctype{#1}}    % thesis, treatise, or dissertation
\def\semester#1{\gdef\@semester{#1}}  % Fall, Spring, or Summer
\def\degree#1{\gdef\@degree{#1}}      % M.S., Ph.D, etc.
\def\submitsemester#1{\gdef\@submitsemester{#1}}
\def\submityear#1{\gdef\@submityear{#1}}
 
% Initialize these fields to blanks.
\def\@title{}
\def\@author{}
\def\@dept{}
\def\@college{}
\def\@doctype{}
\def\@semester{}
\def\@degree{}
\def\@submityear{}
 
\newif\ifcopyright
 
% The default is not to have a copyright notice on the cover page.
\copyrightfalse
 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Define the title page layout.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\maketitlepage{%
\thispagestyle{empty} % No page number on the cover page.
\null\vskip.25in%
\begin{center}
\large THE FLORIDA STATE UNIVERSITY\\
COLLEGE OF \uppercase\expandafter{\@college}
\end{center}
\vfill
\begin{center}
{\Large\uppercase\expandafter{\@title}}
\end{center}
\vfill
\begin{center}
By\\
\large\uppercase\expandafter{\@author}
\end{center}
\vfill
\begin{center}
\baselineskip=13pt
A \@doctype \ submitted to the\\
Department of \@dept\\
in partial fulfillment of the\\
requirements for the degree of\\
\@degree
\end{center}
\vfill
\begin{center}
Degree Awarded:\\
{\@submitsemester} Semester, \@submityear
\end{center}
\ifcopyright
   \vfill
   \begin{center}
      \baselineskip=13pt
      Copyright \copyright\ \@submityear\\
      by \@author\\
   \end{center}
\fi
\vskip 0.5in
\newpage} %end of \maketitlepage definition.
 
%%%%%%%%%%%%%%%%
% Signature page
%%%%%%%%%%%%%%%%
% Define the \sigbox (signature box) command that draws a signature line
% and prints the committee member's name and responsibility.
% Example of use: \sigbox{Jane Q. Doe\\Professor Directing Thesis}
\def\sigbox#1{\parbox{3in} % Define a box for each committee member.
{\vskip 0.75in % Skip 0.75 inch before drawing the signature line.
\baselineskip 13pt % Use single spacing.
{\vrule height 1pt width 3in depth -0.5pt}\\ %Draw the signature line.
#1}} % Insert the name and responsibility of the committee member.
 
%%%%%%%%%%%%%%%
% Miscellaneous
%%%%%%%%%%%%%%%
% For that part of the document before the chapters start,
% number the pages with Roman numerals centered at the bottom of the page.
% Have no "headers" at the top of any of these pages.
\pagenumbering{roman}
\pagestyle{plain}
 
% Define the \tableoftables and \tableoffigures commands.
% Using \addvspace below avoids the extra space that would otherwise
% appear in the lists of figures and tables between entries for
% different chapters.
% It makes no sense to have space between chapters' entries with
% continuous numbering throughout the document.
\def\tableoftables%
  {\addcontentsline{toc}{chapter}{List of Tables}
   \addvspace{10pt}
   \let\saveaddvspace=\addvspace
   \def\addvspace##1{}
   \listoftables
   \let\addvspace=\saveaddvspace}
 
\def\tableoffigures%
  {\addcontentsline{toc}{chapter}{List of Figures}
   \addvspace{10pt}
   \let\saveaddvspace=\addvspace
   \def\addvspace##1{}
   \listoffigures
   \let\addvspace=\saveaddvspace}
 
% end of fsuthesis.sty.
 
---------- End of fsuthesis.sty  and  end of letter ------------------

Schoepf@SC.ZIB-BERLIN.DBP.DE (Rainer Schoepf) (03/25/91)

   From: "George D. Greenwade" <bed_gdg@SHSU.BITNET>
 
 
   On Fri, 22 Mar 1991 16:56:06 EST, Jon E. Ahlquist <AHLQUIST@metsat.met.fsu.e
du>
   submitted the following to LaTeX-help@sumex-aim.stanford.edu.  I am unable t
o
   help Jon directly, but thought that the collective wisdom of
   LaTeX-help-toughies and INFO-TeX would have an answer.  Recall that the
   questioner in this case and the one in need of immediate assistance is:
                            AHLQUIST@metsat.met.fsu.edu
 
   Regards,   George
   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   George D. Greenwade, Ph.D.                            Bitnet:  BED_GDG@SHSU
   Department of Economics and Business Analysis         THEnet: SHSU::BED_GDG
   P. O. Box 2118                                        Voice: (409) 294-1266
   Sam Houston State University                          FAX:   (409) 294-3612
   Huntsville, TX 77341            Internet: bed_gdg%shsu.decnet@relay.the.net
   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
   Dear Sir/Madam:
 
   I am modifying suthesis.sty to create a style for theses at Florida
   State University.  Everything is fine except for one LaTeX problem.
 
   My LaTeX "root" file, thesis.tex, contains the following lines
   as it attempts to set up the appendix section of a thesis:
 
   \addcontentsline{toc}{chapter}{Appendices}
   \appendix
   \include{append_a} % Include appendix A stored in append_a.tex
   \clearpage
 
   (The complete files thesis.tex and fsuthesis.sty are appended
   at the end of this letter just in case I have omitted something
   important from my example.)
   Despite the fact that: \addcontentsline{toc}{chapter}{Appendices}
   precedes:              \include{append_a} \clearpage
   the table of contents file contains the entries in reversed order:
 
   \contentsline {chapter}{\numberline {A}Reaction Rates}{9}
   \contentsline {chapter}{Appendices}{9}
 
   If this were only for myself, I would edit the ".toc" file
   to reverse the lines, but I am trying to prepare something
   that any and all graduate students at Florida State University could use.
   Therefore, I would like to find a "clean" solution to the problem.
   Is there a way to force the \addcontentsline
   message to be written before the chapter listing for appendix A?
 
   Thank you.
 
   - Jon
   Dr. Jon E. Ahlquist, Dept. of Meteorology B161, Florida State University
   Tallahassee, FL 32306-3034
   Telephone: (904) 644-1558
   Internet: ahlquist@met.fsu.edu
   or        ahlquist@metsat.met.fsu.edu
 
The problem comes from an unfortunate interaction between
\addcontentsline and \include.  \addcontentsline works by writing the
relevant information to the .aux file, more precisely, by putting
there a write statement to the .toc file. But this information is only
written when the current page is shipped out, since \write commands
are not executed earlier, unless they are preceded by \immediate.
 
\include, on the other hand, \immediate'ly writes the command
 
\@input{append_a.aux}
 
to the .aux file which means that it comes earlier than the \@writefile
command produced by the \addcontentsline.
 
Since there are these two mechanisms involved, there are two ways to
circumvent this: either you use \input instead of \include, or put the
\addcontentsline and \appendix commands into append_a.tex.
 
Another solution is impossible until the whole .aux file handling has
been rewritten completely.
 
 
I'd like to add one or two comments on the fsuthesis.sty file.
 
First of all, you are making the common mistake to implement your
thesis style as a document style *option*.  Fsuthesis should be a
document style by itself, and replace `report' (which is only an
example document style anyway).
 
Use of report as base document style leads to strange code like the
one in \tableoftables and \tableoffigures.  If you don't want extra
vertical space you should define \@chapter appropriately.
 
Regarding the single spacing in floats and footnotes: isn't a
redefinition of \@parboxrestore exactly what you want?  I'm not sure
about this since it also is applied to the text in a \parbox command
and the minipage environment.
 
Rainer
 
   Dr. Rainer Schoepf
   Konrad-Zuse-Zentrum                       ,,Ich mag es nicht, wenn
    fuer Informationstechnik Berlin            sich die Dinge so frueh
   Heilbronner Strasse 10                      am Morgen schon so
   D-1000 Berlin 31                            dynamisch entwickeln!''
   Federal Republic of Germany
   <Schoepf@sc.ZIB-Berlin.dbp.de> or <Schoepf@sc.ZIB-Berlin.de>