Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
1  
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
add comment

4 Answers 4

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)

screenshot

\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.

share|improve this answer
add comment

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:

screenshot

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

share|improve this answer
add comment

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).

share|improve this answer
add comment

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}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.