# Consistent spacing after section?

Effectively, when I make section titles, I noticed that obviously the space after them is constant, but the letters aren't mono-width, leading to weird discrepancies across them. Is there any way to make the space after a subsubsection to adapt to this so that all the starting lines are aligned?

MWE:

\documentclass{article}
\renewcommand{\thesubsubsection}{\alph{subsubsection})}

\begin{document}
\section{Dolor Sit Amet}
\subsubsection{Lorem Ipsum}
\subsubsection{Lorem Ipsum}
\end{document}


Basically, you want to right align the subsection numbers within a small space.

If this causes problems in the TOC etc., try \hbox to 1em{\hfill...} or use \protect.

\documentclass{article}
\renewcommand{\thesubsubsection}{\makebox[1em][r]{\alph{subsubsection})}}

\begin{document}
\section{Dolor Sit Amet}
\subsubsection{Lorem Ipsum}
\subsubsection{Lorem Ipsum}
\end{document}


This version modifies \@seccntformat. Rather than do a string compare, I defined different formats for every possible \@sect name.

\documentclass{article}
\usepackage{showframe}% alignment tool

\renewcommand{\thesubsubsection}{\alph{subsubsection}}

\makeatletter
\def\@seccntformat#1{\csname #1@format\endcsname}
\makeatother

\begin{document}
\section{Dolor Sit Amet}
\subsubsection{Lorem Ipsum}
\subsubsection{Lorem Ipsum}
\end{document}

• If you redefine \thesubsubsection like this you are also affecting references. It is better to change \@seccntformat. Feb 15, 2020 at 15:18
• @UlrikeFischer how would you go about doing that? Feb 15, 2020 at 15:26
• Note that \@seccntformat is passed section, subsection, etc. as an argument. Feb 15, 2020 at 15:31
• you don't have to define a format for every level. You could do something like \ifcsname #1@format\endcsname \csname#1@format\endcsname \else \csname the#1\endcsname\quad\fi, and then define only the new \subsubsection@format. Feb 15, 2020 at 18:49
• @UlrikeFischer - or use \@ifundefined etc. OTOH, I have always preferred jump vectors to test-and-branch. Feb 16, 2020 at 1:49