# The vertical spacing between the first and the second line in the section formatted with \titleformat

Why is the vertical spacing between the first and the second line in the section greater than the vertical spacing between the rest of the section in this MWE?

\documentclass[12pt]{article}

\usepackage{titlesec}

\titleformat{\section}
[display]
{\fontsize{26}{15}\selectfont}
{\thesection}
{0mm}
{}

\titlespacing*{\section}{0mm}{*0}{0mm}

\begin{document}

\section{PPPPPPPP AAAAAAA VVVIVCCC IA OOOOOIO PPPPPIP PPPPPPPP AAAAAAA VVVIVCCC IA OOOOOIO IA OOOOOIO PPPPPIP PPPPPPPP AAAAAAA VVVIVCCC IA OOOOOIO IA OOOOOIO PPPPPIP PPPPPPPP AAAAAAA VVVIVCCC IA OOOOOIO PPPPPIP}

\vspace{3cm}

\fontsize{26}{15}\selectfont PPPPPPPP AAAAAAA VVVIVCCC IA OOOOOIO PPPPPIP PPPPPPPP AAAAAAA VVVIVCCC IA OOOOOIO IA OOOOOIO PPPPPIP PPPPPPPP AAAAAAA VVVIVCCC IA OOOOOIO IA OOOOOIO PPPPPIP PPPPPPPP AAAAAAA VVVIVCCC IA OOOOOIO PPPPPIP

\end{document}


EDIT Note that \fontsize{26}{15}\selectfont is used in both \titleformat and the document but their impact is different.

• That is because of your font size command in \titleformat. Nov 28 '20 at 9:29
• I know that, it is there on purpose. Note it is in the document but there are no spacing issues. Nov 28 '20 at 12:50

Because titlesec inserts an strut. Just write:

\usepackage[nostruts]{titlesec}


See the manual for further details.

• Excellent! I do not know how I missed it. Have you considered having something like allstruts that will add strut to every line? Nov 29 '20 at 20:56
• Increase the baselineskip. First lines are special in that the space above them is removed in some contexts. Why are you setting such a low baselineskip? Nov 30 '20 at 6:55
• There was no special reason for such, I probably noticed the spacing issue with some other (more appropriate) baselineskip. Dec 11 '20 at 12:47

Modify your fontsize command in \titleformat. Unrelated: I don't understand the reason behind your \titlespacing command, which enforces adding \vspace command before the section body.

\documentclass[12pt]{article}

\usepackage{titlesec}

\titleformat{\section}
[display]
{\fontsize{26}{0}\selectfont}
{\thesection}
{2mm}
{}

\titlespacing*{\section}{0mm}{*0}{0mm}

\begin{document}

\section{PPPPPPPP AAAAAAA VVVIVCCC IA OOOOOIO PPPPPIP PPPPPPPP AAAAAAA VVVIVCCC IA OOOOOIO IA OOOOOIO PPPPPIP PPPPPPPP AAAAAAA VVVIVCCC IA OOOOOIO IA OOOOOIO PPPPPIP PPPPPPPP AAAAAAA VVVIVCCC IA OOOOOIO PPPPPIP}

\vspace{3cm}

\fontsize{26}{15}\selectfont PPPPPPPP AAAAAAA VVVIVCCC IA OOOOOIO PPPPPIP PPPPPPPP AAAAAAA VVVIVCCC IA OOOOOIO IA OOOOOIO PPPPPIP PPPPPPPP AAAAAAA VVVIVCCC IA OOOOOIO IA OOOOOIO PPPPPIP PPPPPPPP AAAAAAA VVVIVCCC IA OOOOOIO PPPPPIP

\end{document}


• Modifying the fontsize is there on purpose. \titlespacing is not relevant here, ignore it. Note the different behavior of \fontsize{26}{15}\selectfont PPPPPPPP AAA... in the document and the section. Nov 28 '20 at 12:53
• I noted that \ I guess there's something in tyhe internals of titlesec that explains this behaviour,. However \fontsize{26}{0} (or {26}{1} if you prefer) seems to solve the problem, if I've well understood what you're rying to obtain. Nov 28 '20 at 13:05
• I am trying to find the root cause of different behavior of \fontsize{26}{15}, and eventually fix it. Nov 28 '20 at 13:12