[comp.text.tex] LaTeX table of contents problem

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

I am in the process of overseeing final production on a project which I
didn't ask for and for which I personally don't approve of the style we are
constrained to (but that's why we have tenure-track professors starting an
academic year in which a tenure election is to be held, isn't it?).  We are
preparing a relatively large report (230+ pages) in what amounts to outline
format.  Peter Halvorson's OUTLINE.STY has been marvelous for this --
proper spacing, enumeration labels, everything precisely as it should be --
floats even work as they should.  I've even taken the work files containing
each chapter, stripped the file-specific preambles, made a master shell
which inputs the files, and produces the final document (at least as final
as "final" is right now).  Again, everything is marvelous.
 
Now the problem.  At commencement exercises today, I was asked by one of
the powers that be on the project, "Oh, by the way, you're generating a
table of contents based on the first, second, and third level items,
right?"  Quick answer by me: "Nope."  It turns out that the official body
to which this report will be in the mail to
                               ON WEDNESDAY
requires a table of contents (this is the first time anyone had even
suggested such a beast to me; even in the illustrations I had to work with,
I never saw a table of contents!).
 
Ran (well, really walked) back to my office thinking, "this will be easy,
just use \addtocontents{toc}{...} for these items and \tableofcontents at
the start, then (a) LaTeX will generate a table of contents and (b) life
will be easy."  Guess what?  (a) it doesn't and (b) it isn't.  Admittedly,
there are no \section'ing commands since the outline style does
*specifically* what it needs to do in terms of output appearance (I'm using
article.sty as the main style), but this just plain doesn't generate
anything worthwhile.  I didn't expect it to be exactly right due to missing
sectioning commands, but did expect it to give me titles and page numbers
so I could work with that by hand (seven first-level items, 42 second-level
items, and 239 third-level items looks like what I should expect).
 
What am I missing?  There has to be something simple I am overlooking.  All
that is at stake is a project the entire faculty of the College has been
working on since January (although I am still waiting on a first draft from
one of the committees which still has to be incorporated prior to
Wednesday's deadline -- I was hoping that it could be keyed in after a
quick editing and sent, but now I face this).  Clearly, I can do the
contents by hand (and probably will for this iteration -- future iterations
are expected, though, so this is not a transient problem), but if anyone
can come up with a quick (and even dirty) trick to do this, I will be
appreciative (especially if you can dream up a way to redefine \item in a
list environment to do this directly, since everything presently is of the
format \item {\bf Leading required text.} Discussion text..... and {Leading
required text.} is what I need in the toc 8-)).
 
Yours in ignorance,   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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

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

The INFO-TeX/comp.text.tex connection comes to the rescue once again!
Charles Geyer (Department of Statistics, University of Chicago)
<geyer@galton.uchicago.edu>, points out:
>> Ran (well, really walked) back to my office thinking, "this will be easy,
>> just use \addtocontents{toc}{...} for these items and \tableofcontents at
>> the start, then (a) LaTeX will generate a table of contents and (b) life
>> will be easy."  Guess what?  (a) it doesn't and (b) it isn't.
 
>> What am I missing?
 
>Don't you want
>
> \addcontentsline{toc}{section}{\numberline {1} Leading required text}
> \addcontentsline{toc}{subsection}{\numberline {1. 5} More leading required
>  text}
> \addcontentsline{toc}{subsubsection}{\numberline {1. 5. 4} Yet more leading
>  required text}
>
>This will at least produce the Table of contents you want.
>
>Redefining \l@section \l@subsection \l@subsubsection in article.sty
>will change the appearance of the table.
 
Yes.  Bless you and thank you.  I got so caught up in my disdirected
playing with \addtocontents that I forgot \addcontentsline!  Although the
appearance of the table is appropriate (for me), it may not be for my
powers-that-be, so the insight on appearance is also appreciated.
 
>> anyone can come up with a quick (and even dirty) trick to do this, I will be
>> appreciative (especially if you can dream up a way to redefine \item in a
>> list environment to do this directly, since everything presently is of the
>> format \item {\bf Leading required text.} Discussion text..... and {Leading
>> required text.} is what I need in the toc 8-)).
 
>Redefining \@item so it does \addcontentsline like \@sect is possible
>maybe, but it would take me longer than I want to spend on a lot of
>experimentation.  Presumably \@listdepth tells you what level you are
>on.
 
Thanks for this insight, as well.  Looking at the code, you are right, it
shouldn't be that big a job to redefine the behavior of \@item to do what I
need.  Glad you didn't use your time on this -- just pointing me in the
proper direction was all I needed.  Due to the time constraint, this may be
put on a to-do list, but it will be seriously investigated.
 
>Have you been carefully studying latex.tex and article.sty?  You can't
>figure stuff like this out from the book.  You have to figure out the
>source.
 
Correct!  Unfortunately, I (quite obviously) didn't know specifically what
to even look for at the time -- long hours associated with finals,
graduation, and this dumb project have pretty much vegged me out.  Although
I was looking at them, "carefully studying" is apparently a very bad
misnomer for what I was doing.
 
>Hope this helps.
 
Indeed it does -- thank and bless you once again!
 
>Disclaimer: I haven't actually tried any of this.
 
Cross-claimer: I have and it works!
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%