[texhax] Adding "\section*" entries to TOC

jfbu jfbu at free.fr
Sun Jun 2 09:29:53 CEST 2013


Le 2 juin 2013 à 02:51, Reinhard Kotucha <reinhard.kotucha at web.de> a écrit :

> On 2013-06-01 at 21:58:52 +0200, jfbu wrote:
> 
>> If you insert
>> 
>> \setcounter{secnumdepth}{0}
>> 
>> at the beginning of the body of the document, and use \section{FOO}
>> without the star, then the TOC will display the (unnumbered) section
>> entries.
> 
> I assume that with "body of the document" you mean everything between
> \begin{document} and \end{document}. 
> 
> You can do this alraedy in the preamble of the document.  The default
> value is set in the document class file.

Not knowing which class was used by the OP, I said that as a
preemptive measure in case some package, or the class, did things
using \AtBeginDocument (or \AtEndPreamble if etoolbox is used).

It is indeed probably cleaner to insert this instruction in the preamble.

Assuming of course (as is a kind of rule in LaTeX concepts of the
look of a document) that the user does not wish to change the
value midways through the document, then there would not be much ground
to put the first such instruction mandatorily in the preamble. 

> 
> A basic idea of LaTeX is to separate content and layout.  Thus, no
> layout instructions should be inserted after \begin{document}.  In
> some cases it cannot be avoided but in these rare cases the macro
> \AtBeginDocument can be used. 
> 
> The ability to keep content and layout separately is an invaluable
> feature of LaTeX.

? well it is a feature, realized to /some/ extent. 

And observe how it (of course one may change it forcefully)
rigidifies the layout at the start. I don't
want to start a war about the pros and cons, but I will just
say that I have observed again and again that masters
systematically forget the amount of sacrificing any apprentice
has to do with respect to initial expectations:

   software is exemplary in that regard: learning to use a
software is learning not to repeat the naive things which
ended up in failure but could have worked. After a while, the
better learners do not attempt anymore anything which reveals
a failure of the software and then, they have learned it. 

   for the more alert, life is like learning step by step that
everything, starting with language, is ultimately a lie. The more
alert is seldom the happier guy.


> 
>> Subsections will not be numbered too, and you can control with the
>> tocdepth counter if they appear or not in the TOC
> 
> If you've set up tocdepth to a value which prevents sections to appear
> in the TOC, the only way to get subsections into the TOC is to use
> \addcontentsline.  "tocdepth" works from top to bottom. 
> 
> Regards,
>  Reinhard
> 

agreed of course,
it was sort of tacit here that the OP would not set tocdepth
to a value preventing even sections to show.

regards,
Jean-Francois




More information about the texhax mailing list