6

I am just looking to confirm what I suspect. Was this programmed to make any negative :

  • have no vertical effect because nobody in their right mind would want overlapping text?
  • Therefore disable indent in inline headings?

If there is more to add, please do! If I am wrong, please tell the real story behind this.

In the source2e document, the \@startsection has this code to deal with indentation on the line directly following a heading.

\@tempskipa #4\relax
\@afterindenttrue
\ifdim \@tempskipa <\z@
  \@tempskipa -\@tempskipa \@afterindentfalse
\fi
2
  • The fourth argument to \@startsection is overloaded: a negative value means “no indentation in the paragraph following the title”, but the space is the absolute value. – egreg Mar 2 '17 at 7:19
  • 1
    You can also have a look at ltsect.dtx, which might---or might not---be helpful. – Johannes_B Mar 2 '17 at 7:25
6

In source2e (or its component ltsect.dtx) you find this documented as

 \begin{macro}{\@startsection}

 The |\@startsection{|\meta{name}|}{|\meta{level}|}{|%
       \meta{indent}|}{|\meta{beforeskip}|}|\\
     |{|\meta{afterskip}|}{|\meta{style}|}*[|\meta{altheading}%
     |]{|\meta{heading}|}|
 command is the mother of all the user level sectioning commands.
 The part after the |*|, including the |*| is optional.

 \begin{description}
 \item[name:] e.g., 'subsection'
 \item[level:] a number, denoting depth of section -- e.g.,
                  chapter = 0, section = 1, etc.
 \item[indent:] Indentation of heading from left margin
 \item[beforeskip:] Absolute value = skip to leave above the heading.
                If negative, then paragraph indent of text following
                heading is suppressed.
 \item[afterskip:] if positive, then skip to leave below heading, else
                negative of skip to leave to right of run-in heading.
 \item[style:] Commands to set style. Since June 1996 release the
               \emph{last} command in this argument may be a command
                such as |\MakeUppercase| or |\fbox| that takes an
                argument. The section heading will be supplied as the
                argument to this command. So setting |#6| to, say,
                |\bfseries\MakeUppercase| would produce bold,
                uppercase headings.
 \end{description}

So a heading specification includes two lengths (before and after skips) and two boolean flags (display-or-inline and indent-or-not) but the flags are encoded by the sign of the skips (which is slightly unfortunate as it means that you can not use 0pt as the skip and still have a choice over the setting of the boolean)

So the code that you show negates \@tempskipa if it is negative so it ends up being the absolute value of the value specified in \@startsection, while at the same time setting the \if@afterindent flag to false to suppress paragraph indentation in the first paragraph after the heading.

3
  • I finally understand it. I know why I did not understand it the first time. TeX register variables can be set implicitly (the operator = is optional)-which makes it difficult for humans to read! The document could do a better job at explaining this. For example: \@tempskipa_OPERAND =_OPERATOR_IMPLICIT -\@tempskipa_OPERAND is the absolute value of #4, because this only occurs when #4 is negative (\ifdim \@tempskipa <\z@). The operator is left out to save on token munching. – Jonathan Komar Mar 2 '17 at 9:38
  • 1
    @macmadness86 in the latex kernel we omit every token that was omittable = spaces, optional {} around arguments that are a single token. Doing so saved several hundred bytes which made the difference between latex2e being able to load into emtex and not fitting:-) – David Carlisle Mar 2 '17 at 10:33
  • I understand. I made that last comment for posterity. Btw, I think the implicit aspects (utilized for sparing bytes) of the LaTeX kernel is the primary reason why the backend is hard for newcomers to grasp. I find that I had to learn how TeX processes everything before I could get something out of source2e. Still, TeX has come a long way since 1978! – Jonathan Komar Mar 2 '17 at 12:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.