# No space between section heading and numbering

I'd like my section headings to be displayed directly after the section numbering with no space in between. This should be the case regardless of the number. Something like this:

1. A section heading
...
1526. Yet another section


Currently I'm using titlesec with

\titleformat{\section}{\large\bfseries}{\makebox[1pt][l]{\thesection}}{12pt}{}


but this causes heading and large numbers to overlap.

-
I've some doubts this being typographycally sound: at least a normal space should follow the dot. –  egreg Oct 31 '12 at 12:52
@egreg You're right, a normal space is required –  Jakub Oct 31 '12 at 12:56
Welcome to TeX.sx! –  Corentin Oct 31 '12 at 13:07
–  Jakub Apr 6 '13 at 14:07

Update: there's an easier solution with titlesec: the \thetitle command is respectively \thesection, \thesubsection, etc. The default value in standard classes is:

\titlelabel{\thetitle\quad}


which means that after the number, an space of 1em is inserted; to change this behaviour is enough then to redefine \thetitle to add a dot and then a space:

\titlelabel{\thetitle.\ }


A complete example:

\documentclass{article}
\usepackage{titlesec}

\setcounter{secnumdepth}{5}% just for the example

\titlelabel{\thetitle.\ }

\begin{document}

\section{Test Section}
\subsection{Test Subsection}
\subsubsection{Test Subsubection}
\paragraph{Test Paragraph}
\subparagraph{Test Subparagraph}

\section*{Test Section}
\subsection*{Test Subsection}
\subsubsection*{Test Subsubection}
\paragraph*{Test Paragraph}
\subparagraph*{Test Subparagraph}

\end{document}


One possibility using the titlesec package affecting \section through \subparagraph:

\documentclass{article}
\usepackage[explicit]{titlesec}

\setcounter{secnumdepth}{5}% just for the example

\titleformat{\section}
{\normalfont\Large\bfseries}{\thesection.}{0em}{~#1}
\titleformat{name=\section,numberless}
{\normalfont\Large\bfseries}{}{0em}{#1}
\titleformat{\subsection}
{\normalfont\large\bfseries}{\thesubsection.}{0em}{~#1}
\titleformat{name=\subsection,numberless}
{\normalfont\large\bfseries}{}{0em}{#1}
\titleformat{\subsubsection}
{\normalfont\normalsize\bfseries}{\thesubsubsection.}{0em}{~#1}
\titleformat{name=\subsubsection,numberless}
{\normalfont\normalsize\bfseries}{}{0em}{#1}
\titleformat{\paragraph}[runin]
{\normalfont\normalsize\bfseries}{\theparagraph.}{0em}{~#1}
\titleformat{name=\paragraph,numberless}[runin]
{\normalfont\normalsize\bfseries}{}{0em}{#1}
\titleformat{\subparagraph}[runin]
{\normalfont\normalsize\bfseries}{\thesubparagraph.}{0em}{~#1}
\titleformat{name=\subparagraph,numberless}[runin]
{\normalfont\normalsize\bfseries}{}{0em}{#1}

\begin{document}

\section{Test Section}
\subsection{Test Subsection}
\subsubsection{Test Subsubection}
\paragraph{Test Paragraph}
\subparagraph{Test Subparagraph}

\end{document}


I can't upload images; will do it later.

-
Thanks! This seems to work perfectly for me. I could use some explanation, though. –  Jakub Oct 31 '12 at 13:16
@Jakub of course; I am really busy right now, but in a few hours I'll add some explanatory comments. –  Gonzalo Medina Oct 31 '12 at 18:03
@Jakub I found an even simpler solution; I updated my answer showing this simpler possibility. –  Gonzalo Medina Oct 31 '12 at 22:54

The simplest way, without any package, is to redefine \@seccntformat, which usually adds \quad after the section number:

\documentclass{article}
\usepackage[pass,showframe]{geometry}
\makeatletter
\def\@seccntformat#1{\csname the#1\endcsname.\ }
\makeatother

\setcounter{secnumdepth}{10}

\begin{document}
\section{Test Section}
\subsection{Test Subsection}
\subsubsection{Test Subsubection}
\paragraph{Test Paragraph}
\subparagraph{Test Subparagraph}
\section*{Test Section}
\subsection*{Test Subsection}
\subsubsection*{Test Subsubection}
\paragraph*{Test Paragraph}
\subparagraph*{Test Subparagraph}
\end{document}


The \ command after the dot ensures that the space is not affected by the space factor; so the space doesn't grow if \nonfrenchspacing, the default setting in LaTeX, is in force: it's a normal interword space in the current font.

I've used geometry only to add the frame; the setting of secnumdepth is only for demonstration purposes, I don't recommend going too deep in the numbering of sectional units.

-