[Tex/LaTex] Indent only first line in multi-line subsection header

indentationsectioning

I'm requested that my subsection titles look like this:

However, so far I didn't manage to achieve that. titlesec documentation didn't help much. The best I could get is something like this:

with \titleformat{\subsection[block]{\large\bfseries}{\thesubsection}{1ex}{}. I feel like I could remove indent of the block completely and then add \parindent to the title style, but that seems wrong to me.

I would really appreciate any help!


Edit. I managed to do this in a very ugly way:

\usepackage[compact]{titlesec}
\titleformat{\subsection}[block]
    {\large\bfseries}
    {\hspace{1cm}\thesubsection}
    {1ex}{}
\titlespacing*{\subsection}{0pt}{4em}{3em}

It somehow does what I need:

enter image description here

However, I feel bad for doing this. If there is any better way of doing this, it would be very helpful!

Best Answer

Using the titlesec package, you can use your approach:

\titleformat{\subsection}[block]
    {\large\bfseries}
    {\hspace{1cm}\thesubsection}
    {1ex}{}

but I would like to present you another option, using the runin format (for a run-in title) and then, the first mandatory argument of \titleformat that allows you to specify (in the runin format) the indentation just before the title; a little example using some of your settings:

\documentclass{article}
\usepackage[compact]{titlesec}
\usepackage{lipsum}% just to generate some text for the example

\titleformat{\subsection}[runin]
  {\normalfont\Large\bfseries}{\thesubsection}{1em}{}[{\\[2em]}]
\titlespacing*{\subsection}{1cm}{4em}{0em}

\begin{document}

\section{Test Section}

\subsection{Test Subsection with a Long Title that Spans Two Lines}
\lipsum[4]

\end{document}

enter image description here