5

I have some subsubsection-titles that break the line and some that don't. The spacing after the title is different for those two cases. I am currently using so many packages and stuff (titlsec is one of them) and I tried to find a MWE that reproduces the problem:

\documentclass[twocolumn]{article}
\usepackage{lipsum}
\RequirePackage[explicit]{titlesec}

\titleformat{name=\subsubsection,numberless}
      {\normalsize\sffamily\bfseries}
      {}
      {0em}
      {\parbox[t]{\linewidth}{\raggedright#1}}
      [] 
 \titlespacing*{\subsubsection}{0pc}{1.7ex \@plus2pt \@minus1pt}{0pt}

\begin{document}

\subsubsection*{Some long long long long text that should break the line}
\lipsum[2]

\subsubsection*{some other text}
\lipsum[2]

\end{document}

Does anyone have any idea why this weird spacing may occur?

4

The problem is the \parbox[t] which is unnecessary.

\documentclass[twocolumn]{article}
\usepackage{lipsum}
\usepackage{titlesec}

\titleformat{name=\subsubsection,numberless}
  {\normalsize\sffamily\bfseries}
  {}
  {0em}
  {\raggedright}

\titlespacing*{\subsubsection}{0pc}{1.7ex plus 2pt minus 1pt}{0pt}

\begin{document}

\subsubsection*{Some long long long long text that should break the line}
\lipsum[2]

\subsubsection*{some other text}
\lipsum[2]

\end{document}

enter image description here

For numbered subsubsections, you might do something like this:

\documentclass[twocolumn]{article}
\usepackage{lipsum}
\usepackage{titlesec}

\newlength\mylena
\setlength\mylena{1.3cm}

\titleformat{name=\subsubsection}[block]
 {\normalsize\sffamily\bfseries}
 {}
 {0em}
 {\makebox[\mylena][l]{\thesubsubsection}%
  \raggedright\hangindent\mylena}

\titleformat{name=\subsubsection,numberless}[block]
  {\normalsize\sffamily\bfseries}
  {}
  {0pt}
  {\raggedright}

\makeatletter
\titlespacing*{\subsubsection}{0pt}{1.7ex \@plus2pt \@minus1pt}{0pt}
\makeatother

\begin{document}

\subsubsection{Some long long long long text that should break the line}
\lipsum[2]

\subsubsection*{Some long long long long text that should break the line}
\lipsum[2]

\subsubsection{some other text}
\lipsum[2]

\end{document}

enter image description here

  • This works thank you. But for the numbered subsubsections (and also sections) I guess I need parbox for the align, how can I make the weird spacing disappear in this case?: \newlength\mylena \newlength\mylenb \setlength\mylena{1.3cm} \setlength\mylenb{\dimexpr\columnwidth-\mylena\relax} \titleformat{\subsubsection} {\normalsize\sffamily\bfseries} {} {0em} {\PlaceNumber{\thesubsection}\parbox[t]{\mylenb}{\raggedright#1}} [] – Kathiieee Aug 20 '13 at 14:56
  • @Kathiieee The third argument is intended for the number. Please, read the manual for further details. – Javier Bezos Aug 20 '13 at 15:54
  • @Kathiieee I added a solution for numbered subsections – egreg Aug 20 '13 at 19:25
4

Whenever you see "weird spacing" suspect \lineskip :

\documentclass[twocolumn]{article}
\usepackage{lipsum}
\RequirePackage[explicit]{titlesec}

\showoutput
\showboxdepth6

\titleformat{name=\subsubsection,numberless}
      {\normalsize\sffamily\bfseries}
      {}
      {0em}
      {\parbox[t]{\linewidth}{\raggedright#1}}
      [] 
 \titlespacing*{\subsubsection}{0pc}{1.7ex \@plus2pt \@minus1pt}{0pt}

\begin{document}

\subsubsection*{Some long long long long text that should break the line}
\lipsum[2]

\subsubsection*{some other text}
\lipsum[2]

\end{document}

The log shows:

......\glue(\lineskip) 1.0

By using a parbox[t] you lose information about the bottom baseline of the heading so TeX can not ensure correct baseline spacing and inserts its fallback \lineskip

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.