3

Can anybody explain to me what this

\section

code does in the following definition:

\renewcommand\section{\@startsection {section}{1}{\z@}%
                   {-2.5ex \@plus -1ex \@minus -.2ex}%
                   {1.3ex \@plus.2ex}%
                   {\normalfont\Large\bfseries}}

In particular, what does @ do, and why aren't \@minus and \@plus evaluated immediately but, on the contrary, given both?

4

1 Answer 1

4

Yes, it's weird. \section in the regular use-case can have any of the following 3 input styles:

\section{<title>}
\section[<ToC title>]{<title>}
\section*{<title>}

However, it's not clear how any of these relate to its definition (in article.cls):

\renewcommand\section{\@startsection {section}{1}{\z@}%
                   {-2.5ex \@plus -1ex \@minus -.2ex}%
                   {1.3ex \@plus.2ex}%
                   {\normalfont\Large\bfseries}}

That's because \section uses \@startsection that actually defines a large number of spacing and formatting parameters. In fact, \@startsection itself is just an intermediary macro that grabs only 6 arguments (from latex.ltx)

\def\@startsection#1#2#3#4#5#6{%
  \if@noskipsec \leavevmode \fi
  \par
  \@tempskipa #4\relax
  \@afterindenttrue
  \ifdim \@tempskipa <\z@
    \@tempskipa -\@tempskipa \@afterindentfalse
  \fi
  \if@nobreak
    \everypar{}%
  \else
    \addpenalty\@secpenalty\addvspace\@tempskipa
  \fi
  \@ifstar
    {\@ssect{#3}{#4}{#5}{#6}}%
    {\@dblarg{\@sect{#1}{#2}{#3}{#4}{#5}{#6}}}}

before handing it over to \@ssect or \@dblarg, depending on whether you used \section or \section*. That's why it's odd - \section is defined to not take any arguments, yet we can supply it with arguments; that's because the arguments are taken and processed by secondary macros contained within \section and deeper.

For more detail about what each argument in \@startsection does, see Where can I find help files or documentation for commands like \@startsection for LaTeX?.


Specifically, the spacing arguments passed to \@startsection contain glue-like lengths which, in general, have the following format

<lengthA> <plus> <lengthB> <minus> <lengthC>

Since the LaTeX kernel defines \@plus/\@minus to be plus/minus, users often mix these as needed. In short the format suggests that the resulting length could be anything between

<lengthA> + <lengthB>

(at maximum) and

<lengthA> - <lengthC>

(at minimum). Specific to the 4th argument of \@startsection, the (vertical) beforeskip for a \section could be as small as 2.3ex (2.5ex - .2ex) or as large as 3.5ex (2.5ex + 1ex)*. Similarly, the afterskip ranges between 1.3ex and 1.5ex (1.3ex + .2ex). The actual value used depends on the other contents used to fill the page (since this glue/stretch is vertical).

* Note that \@startsection's 4th argument sign (positive or negative) is removed from the length calculation and actually denotes the use/suppression of paragraph indentation following a \section. See Where can I find help files or documentation for commands like \@startsection for LaTeX? for details.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .