# Welcome to the UK List of TeX Frequently Asked Questions on the Web

## 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:

\renewcommand*{\@seccntformat}[1]{%
}


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]{%
}


However, many people want to modify section numbers, but not subsection numbers, 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]{%
\csname the#1\endcsname
}


which uses a second-level command to provide the dot, if it has been defined; otherwise it merely appends \relax (which does nothing in this context). The definition of the second-level command (the version for the section, here) specifies what to put after a section number, but it could be used to put anything after it:

\newcommand*{\adddot@section}{.}


Note that all the command definitions above 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); catalogue entry

Go to previous question, or next question

Go to FAQ home.

URL for this question: http://www.tex.ac.uk/cgi-bin/texfaq2html?label=seccntfmt

Comments, suggestions, or error reports? - see “how to improve the FAQ”.

This is FAQ version 3.27, released on 2013-06-07.