1

I'm using the titlesec package to have runin subsection titles. However, I only want this some of the time, and if I try to break the line with \ it either throws an error to adds some weird indentation. Can anyone help?

% Inline subsection
\usepackage{titlesec}
\titleformat{\subsection}[runin]% runin puts it in the same paragraph
        {\bfseries}% formatting commands to apply to the whole heading
        {\thesubsection}% the label and number
        {0.5em}% space between label/number and subsection title
        {\large}% formatting commands applied just to subsection title
        []% punctuation or other commands following subsection title
0

Here, try this:

\subsubsection{My header (singled out)}
\paragraph{}\noindent
% paragraph

If you use it often, you can put it into a command

\newcommand{\singlesubsec}[1]{\subsection{#1}\paragraph{}\noindent}

which you would then use (to replace the above) as

\singlesubsec{My header (singled out)}
% paragraph

MWE:

\documentclass{article}

% Inline subsection
\usepackage{titlesec}
\titleformat{\subsection}[runin]% runin puts it in the same paragraph
        {\bfseries}% formatting commands to apply to the whole heading
        {\thesubsection}% the label and number
        {0.5em}% space between label/number and subsection title
        {\large}% formatting commands applied just to subsection title
        []% punctuation or other commands following subsection title
        
\usepackage{lipsum} % just for dummy text
        
\begin{document}

    \subsection{Header in-line}
    
    \lipsum[1]
    
    \subsection{Header on own}
    \paragraph{}\noindent
    \lipsum[1]
    
\end{document}

enter image description here

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.