Adjusting the presentation of section numbers

The general issues of adjusting the appearance of section headings are pretty complex, and are covered in the question on the style of section headings.

However, people regularly want merely to change the way the section number appears in the heading, and some such people don’t mind writing out a few macros. This answer is for them.

The section number is typeset using the LaTeX internal \@seccntformat command, which is given the “name” (section, subsection, …) of the heading, as argument. Ordinarily, \@seccntformat merely outputs the section number, and then a \quad of space. Suppose you want to put a stop after every section (subsection, subsubsection, …) number, a trivial change may be implemented by simple modification of the command:

\renewcommand*{\@seccntformat}[1]{%
  \csname the#1\endcsname.\quad
}

Many people (for some reason) want a stop after a section number, but not after a subsection number, or any of the others. To do this, one must make \@seccntformat switch according to its argument. The following technique for doing the job is slightly wasteful, but is efficient enough for a relatively rare operation:

\renewcommand*{\@seccntformat}[1]{%
  \expandafter\ifx\csname @seccntformat@#1\endcsname\relax
    \expandafter\@@seccntformat
  \else
    \expandafter
      \csname @seccntformat@#1\expandafter\endcsname
  \fi
    {#1}%
}

which looks to see if a second-level command has been defined, and uses it if so; otherwise it uses the original. The second-level command to define stops after section numbers (only) has the same definition as the original “all levels alike” version:

\newcommand*{\@seccntformat@section}[1]{%
  \csname the#1\endcsname.\quad
}

Note that all the command definitions of this answer are dealing in LaTeX internal commands, so the above code should be in a package file, for preference.

The Koma-script classes have different commands for specifying changes to section number presentation: \partformat, \chapterformat and \othersectionlevelsformat, but otherwise their facilities are similar to those of “raw” LaTeX.

KOMA script bundle
macros/latex/contrib/koma-script (or browse the directory)

This question on the Web: http://www.tex.ac.uk/cgi-bin/texfaq2html?label=seccntfmt