6.8.3 \@startsection examples

Some examples of using \@startsection follow.

This first example puts section titles in large boldface type, centered. As is typical, it uses \renewcommand because LaTeX’s standard classes have already defined a \section. For the same reason it does not define a section counter, or the commands \thesection and (for the table of contents) \l@section.

\renewcommand\section{%
  \@startsection{section}         % name
    {1}                           % level
    {0pt}                         % indent
    {-3.5ex plus -1ex minus -.2ex}% beforeskip
    {2.3ex plus.2ex}              % afterskip
    {\centering\normalfont\Large\bfseries}% style
}

This example puts subsection titles in small caps type, inline with the paragraph, and avoids extra space after punctuation:

\renewcommand\subsection{%
  \@startsection{subsection}       % name
    {2}                            % level
    {0em}                          % indent
    {-1ex plus 0.1ex minus -0.05ex}% beforeskip
    {-1em plus 0.2em}              % afterskip
    {\frenchspacing\scshape}       % style
}

The previous examples redefined existing sectioning commands. This last one defines a new command (\subsubparagraph), illustrating how to define the needed counter and macros. We use a negative afterskip to make the heading a run-in.

% show counters even farther down:
\setcounter{secnumdepth}{6}
%
% define the new counter for numbering:
\newcounter{subsubparagraph}[subparagraph]
%
% how to display the number:
\renewcommand{\thesubsubparagraph}
  {\thesubparagraph.\@arabic\c@subsubparagraph}
%
% the new command itself, which can just call \@startsection:
\newcommand{\subsubparagraph}{
  \@startsection{subsubparagraph}% name
     {6}                     % level
     {0em}                   % indent
     {\baselineskip}         % beforeskip
     {-2em}                  % afterskip, negative for run-in
     {\normalfont\normalsize}% style
}
%
% \l... is how it gets output in the table of contents:
\newcommand*\l@subsubparagraph{\@dottedtocline{6}{10em}{5em}}
%
% \...mark is how it's shown in page headers; in this case, ignored:
\newcommand{\subsubparagraphmark}[1]{}

Unofficial LaTeX2e reference manual