[Tex/LaTex] Too much vertical space after long section title using titlesec

sectioningspacingtitlesec

I'm using titlesec to change the style of my section titles. Sometimes, when the title is long, but just short enough to fit on one line, some extra vertical spaces is add. The following MWE illustrates the problem:

\documentclass{book}
\usepackage[a4paper]{geometry}
\usepackage[explicit]{titlesec}

\titleformat{\section}[block]{\Large\normalfont\bfseries}{#1}{.5em}{}

\begin{document}
  \section{This is a short title}
  This is a paragraph.

  \section{This is a purposely long title that shows some odd behavior}
  This is a paragraph.
\end{document}

This is rendered as follows:

enter image description here

Clearly, there is too much space below the second section title. I've played around with \ignorespaces and \ignorespacesafterend, but can't seem to get rid of the extra space. What to do?

Best Answer

This is above all due to the bad syntax in:

\titleformat{\section}[block]{\Large\normalfont\bfseries}{#1}{.5em}{}

You've put #1 at the place reserved for formatting the label. A correct syntax would be, e.g.:

\titleformat{\section}[block]{\Large\normalfont\bfseries}{\arabic{section}.}{.5em}{#1}

enter image description here

Related Question