3

How do i change the small horizontal spacing that is present before a section number?

I have used the command \titlespacing from package titlesec to set the left spacing to 0, but it is still present. Small example

\documentclass[12pt,a4paper,titlepage]{article}
\usepackage{titlesec}
\titleformat{\section}[display]{\normalfont \bfseries}{\hspace{0mm} \thesection}{1em}{}
\titlespacing{\section}{0pt}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}
\begin{document}
\section{Section title}

Lorem ispum dolor sit amet Lorem ispum dolor sit amet Lorem ispum dolor sit amet Lorem ispum dolor sit amet Lorem ispum dolor sit amet Lorem ispum dolor sit amet Lorem ispum dolor sit amet Lorem ispum dolor sit amet 

\end{document}

If you look at the output, "Section title" is aligned to the second line of text perfectly, whereas the section number "1" is slightly moved to the right.

1
  • 3
    Use only \thesection, not \hspace{0mm} \thesection.
    – Werner
    Commented Jun 2, 2013 at 14:11

1 Answer 1

4

in your definition of \titleformat, the "real" space between

\hspace{0mm} \thesection}{1em}{}

is interpreted by latex as ... a space. just get rid of it:

\hspace{0mm}\thesection}{1em}{}
2
  • \hspace{0mm} can also be deleted. Commented Jun 2, 2013 at 14:15
  • Oh my, you are right. I add spaces everywhere for better readability, but in this case it shot me in the face.
    – alcroito
    Commented Jun 2, 2013 at 14:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .