Full width section titles in scrartcl with parskip option

parskipscrartclsectioning

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}

Best Answer

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.

Related Question