There is the issue of end of sentence space vs. space between words. By default the first one is bigger.
\documentclass{article}
\begin{document}
\noindent
e.g. this and that\\
e.g.\ this and that
\end{document}
In the first line the space after the 2nd period is typeset like an end of sentence space. In the second line the space after the 2nd period is typeset like a normal inter-word space:
You can setup with \frenchspacing
that the end of sentence space is not different from the normal inter-word spacing.
An \@
before a period sets up end of sentence spacing. This is needed, if the sentence ends with a one-capital-letter word.
Without any additional packages, you need to update the fifth argument to \@startsection
and make it negative - implicitly passed with a call to \subsubsection
:
\documentclass{article}
\begin{document}
\section{A section} Some text
\subsection{A subsection} Some text
\subsubsection{A subsubsection} Some text
\makeatletter
\renewcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}%
{-3.25ex\@plus -1ex \@minus -.2ex}%
{-1.5ex \@plus -.2ex}% Formerly 1.5ex \@plus .2ex
{\normalfont\normalsize\bfseries}}
\makeatother
\section{A section} Some text
\subsection{A subsection} Some text
\subsubsection{A subsubsection} Some text
\end{document}
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
:
\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}}}}
\def\@sect#1#2#3#4#5#6[#7]#8{%
\ifnum #2>\c@secnumdepth
\let\@svsec\@empty
\else
\refstepcounter{#1}%
\protected@edef\@svsec{\@seccntformat{#1}\relax}%
\fi
\@tempskipa #5\relax
\ifdim \@tempskipa>\z@
\begingroup
#6{%
\@hangfrom{\hskip #3\relax\@svsec}%
\interlinepenalty \@M #8\@@par}%
\endgroup
\csname #1mark\endcsname{#7}%
\addcontentsline{toc}{#1}{%
\ifnum #2>\c@secnumdepth \else
\protect\numberline{\csname the#1\endcsname}%
\fi
#7}%
\else
\def\@svsechd{%
#6{\hskip #3\relax
\@svsec #8}%
\csname #1mark\endcsname{#7}%
\addcontentsline{toc}{#1}{%
\ifnum #2>\c@secnumdepth \else
\protect\numberline{\csname the#1\endcsname}%
\fi
#7}}%
\fi
\@xsect{#5}}
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 using
\ifdim \@tempskipa>\z@
%... \@tempskipa (or #5) is positive
\else
%... \@tempskipa (or #5) is negative
\fi
The evaluation references \z@
or 0pt
(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
:
\newcommand\paragraph{\@startsection{paragraph}{4}{\z@}%
{3.25ex \@plus1ex \@minus.2ex}%
{-1em}%
{\normalfont\normalsize\bfseries}}
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.
Best Answer
the ams document classes provide the command
\nopunct
to omit the automatically added period at the end of (sub)section headings.the rationale is that a heading might reasonably end with a question mark or similar, so no additional punctuation is wanted. since tex doesn't process backwards, this has to be specified manually.