0

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}

enter image description here

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

2
  • 1
    That is because of your font size command in \titleformat.
    – Bernard
    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.
    – ivankokan
    Nov 28 '20 at 12:50
2

Because titlesec inserts an strut. Just write:

\usepackage[nostruts]{titlesec}

See the manual for further details.

3
  • Excellent! I do not know how I missed it. Have you considered having something like allstruts that will add strut to every line?
    – ivankokan
    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.
    – ivankokan
    Dec 11 '20 at 12:47
0

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} 

enter image description here

3
  • 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.
    – ivankokan
    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.
    – Bernard
    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.
    – ivankokan
    Nov 28 '20 at 13:12

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.