Using the article document class, how can one remove the newline at the end of a subsubsection title?
I am using \documentclass{article}
; I do not currently use titlesec
or any of the alternatives; I do use fancyhdr
.
formattingsectioningsections-paragraphs
Using the article document class, how can one remove the newline at the end of a subsubsection title?
I am using \documentclass{article}
; I do not currently use titlesec
or any of the alternatives; I do use fancyhdr
.
Best Answer
Without any additional packages, you need to update the fifth argument to
\@startsection
and make it negative - implicitly passed with a call to\subsubsection
:This may seem like magic... that is, why the fifth argument, and why does it have to be negative. To see why, you have to follow the chain of execution within the LaTeX kernel. The relevant code addressing this is contained within
\@startsection
and\@sect
:In the above code, keep the focus on the fifth argument, denoted by
#5
in\@startsection
. Although nothing happens to it inside\@startsection
, it passes#5
also as the fifth argument to\@sect
. So, inside\@sect
,#5
is the length stored in\@tempskipa
and subsequently evaluated usingThe evaluation references
\z@
or0pt
(see What does\z@
do?) and therefore designates a choice between\@tempskipa
being positive or negative. The construction inside\else
is what you're after, since it does not include a\@@par
(or line/paragraph break). As a comparison, see the definition of\paragraph
:Note that argument
#5
is negative (-1em
).A brief summary of the above discussion is included in the kernel documentation, also covered in Where can I find help files or documentation for commands like
\@startsection
for LaTeX?Using packages like
titlesec
removes this magic in a more user-friendly way. For an example, see Subsection starting in same line as subsection name.