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.

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

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}{}
  • \hspace{0mm} can also be deleted. – Gonzalo Medina Jun 2 '13 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. – Placinta Jun 2 '13 at 14:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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