# Spacing in headline from beginning of line to title (excluding the section number)

How do I change the spacing between the number and the title of a section? I would like to achieve the following:

1. (1 cm space BUT from the very beginning of that line!) Section title

In Spacing in headline between number and text I basically asked the same question, but with – what I only realized afterwards – a very important difference, i.e. where to start measuring that space! So, what I really want is a constant space of – for instance 1 cm – measured from the beginning of the line and NOT just the space between section number and section title.

-
Since you have some responses below that seem to answer your question, please consider marking one of them as ‘Accepted’ by clicking on the tickmark below their vote count. This shows which answer helped you most, and it assigns reputation points to the author of the answer (and to you!). –  lockstep Jan 21 '12 at 16:19

Here's a solution very similar to the solution in your previous question, except it uses \rlap in the definition of the section title, so that the section number doesn't take up any space (from TeX's point of view)

\documentclass{article}

\usepackage[showframe=true]{geometry}
\usepackage[explicit]{titlesec}

\titleformat{\section}%
{\Large\bfseries}% format
{\rlap{% label
\thesection}\hspace{1cm}#1}%
%{\thesection #1}%
{0pt}% horizontal sep
{}% before

\begin{document}
\section{First section}

\setcounter{section}{14}
\section{Another section}
\end{document}


You might run into problems if the section number gets high, or has the chapter number included as part of it.

-

Here's a solution using ConTeXt:

You can use the command \setuphead with the parameter numberwidth.

\setuphead [chapter, section] [numberwidth=3cm]

\starttext

\startsection [title=Foo]
\blackrule [height=1ex, width=3cm] % just for demonstration
\input knuth
\stopsection

\stoptext


This results in:

The rule is just used for demonstration to have a measure of 3cm.

-

A "no package" solution.

\documentclass{article}

\makeatletter
\def\@seccntformat#1{\protect\makebox[1cm][l]{\csname the#1\endcsname}}
\makeatother

\begin{document}
\noindent\rule{1cm}{1pt}

\section{First Section}
\setcounter{section}{14}
\section{Another Section}
\end{document}


The same spacing will be applied to lower level sections (when numbered).

-

If you are still using a KOMA-Script class a no catcode change suggestion:

\documentclass{scrartcl}

\renewcommand*{\othersectionlevelsformat}[3]{%
\makebox[1cm][l]{#3}%
}

\begin{document}
\section{Section}
\subsection{Subsection}
\subsubsection{Subsubsection}

\end{document}


If you like, you may use different indent in different levels:

\documentclass{scrartcl}

\renewcommand*{\othersectionlevelsformat}[3]{%
\ifstr{#1}{section}{\makebox[1cm]}{%
\ifstr{#1}{subsection}{\makebox[1.5cm]}{\makebox[2cm]}}%
[l]{#3}%
}

\begin{document}
\section{Section}
\subsection{Subsection}
\subsubsection{Subsubsection}
\setcounter{section}{10}\section{Section}
\subsection{Subsection}
\subsubsection{Subsubsection}

\end{document}

-