1

The subsection title in the following document should fit in a single line. The last word slips into the second line, although there is still enough space in the first.

\documentclass[parskip = half+]{scrartcl} 

\usepackage{sectsty}
\usepackage{lipsum}

\begin{document}

\subsection*{This subsection title should fit in a single line but it doesn't}

\lipsum

\end{document}

If I waive the parskip = half+ option the title is in a single line but I need that option for other purposes.

Update

I need the sectsty package to change the part format. The parbox workaround causes the page number in the table of contents to be too far to the right.

\documentclass[parskip = half+]{scrartcl} 
\usepackage{lipsum}
\usepackage{sectsty}
\partfont{\centering\fontsize{20}{30}\selectfont}

\begin{document}
    \tableofcontents
    \addpart{Part}
    \section{This section title should fit in a single line but it doesn't}
    \lipsum[10]
    \section{\parbox{\linewidth}{This section title should fit in a single line but it doesn't}} 
    \lipsum[10]
\end{document}

1 Answer 1

0

The solution is to get rid of secsty and configure the part format using setkomafont instead:

\documentclass[parskip = half+]{scrartcl} 
\setkomafont{part}{\fontsize{20}{30}\selectfont}
\renewcommand{\raggedpart}{\centering}
\usepackage{lipsum}

\begin{document}
    \tableofcontents
    \addpart{Part}
    \section{This section title should fit in a single line and now it does}
    \lipsum[10]
\end{document}

Edit: apply esdds hint.

1
  • \centering is not a font command. Use \renewcommand{\raggedpart}{\centering} to center the part heading and \setkomafont{part}{\fontsize{20}{30}\selectfont} for the part font.
    – esdd
    Feb 13, 2022 at 19:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .