Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LaTeX: typesetting chapter and section number in margin

I'm trying to typeset something in LaTeX and I would like to know if I'm doing it right. The basic idea is that section number hangs in the left margin. The number takes the height of the header+2 lines for a chapter heading, +1 line for section heading, and has the same height as the header for subsections, and is aligned to the top of the heading. See the following image to get an idea of what I'm talking about:

http://img62.imageshack.us/img62/8404/bladld.png

My approach is using titlesec and doing something like this:

\titleformat{\chapter}%
            {\Huge\bfseries\sffamily}% format
            {\vbox to 16pt{\llap{% label
               \fontsize{3em}{0}\selectfont{\thechapter}%
               \hskip 9pt%
            }}}%
            {0pt}% horizontal sep
            {}% before

\titlespacing*{\chapter}%
              {0pt}% left
              {-2em}% before
              {0pt}% after

But this solution has some hacks that I would rather avoid. The \vbox height for instance, is found by trial and error. Visually, it looks almost right...

like image 285
Giovanni Funchal Avatar asked May 19 '10 13:05

Giovanni Funchal


People also ask

How do you number a section in LaTeX?

To put numbering and to show the subsubsection in table of contents, we need to define the counter value of “`tocdepth`” and “`secnumdepth`” in the preamble of your LaTeX document using “`\setcounter`”. Hope this helps.

How do I change the number of sections in LaTeX?

LaTeX lets you change the appearance of the sectional units. As a simple example, you can change the section numbering to upper-case letters with \renewcommand\thesection{\Alph{section}} in the preamble (see \alph \Alph \arabic \roman \Roman \fnsymbol : Printing counters).

What does section * mean in LaTeX?

Brief Answer. The brief answer is, \section inserts a new entry into the table of contents at the appropriate tree-level and also inserts a new entry into the navigation bars. But \section* only adds an entry in the navigation bars, not in the table of contents.


1 Answers

Try using the memoir document class. That has a ton of options for doing exactly this kind of thing, and it's much neater...

There's a hangnum style and for sections, there's a \hangsecnum option, but that only puts the number in the margin: it doesn't make it bigger. Memoir is also fabulously documented. So I expect all everything you need will be there. The code for hangnum is on p.88 of the fantastic memoir manual. So from there and from later examples you should get all the pointers you need to get what you want...

like image 133
Seamus Avatar answered Oct 28 '22 15:10

Seamus