8

I'm trying to make a runin subsubsection title with a long dash inserted after the title. I managed to do it but there are subtle differences in spacing after the dash. I would like to have the same output as in the second paragraph (that does not use the subsubsection).

\documentclass[12pt]{article}
\usepackage{lipsum, titlesec}

\titleformat{\subsubsection}[runin]
            {\normalfont\sffamily\bfseries}{}{0em}{}[ --- ]

\begin{document}
\subsubsection{A brand new template} Until now, we have have been using
a combination of markdown and pandoc for producing both the draft and the final
version of an article.\\

\noindent \textbf{\sffamily A brand new template ---} Until now, we have have
been using a combination of markdown and pandoc for producing both the draft
and the final version of an article.
\end{document}

Output

3 Answers 3

4

You have to change \titlespacing for the subsubsection command, too:

\documentclass[12pt]{article}
\usepackage{lipsum, titlesec}

\titleformat{\subsubsection}[runin]
  {\normalfont\sffamily\bfseries}
  {}{0em}{}
  [\mbox{ --- }]
\titlespacing{\subsubsection}
  {0pt}% left
  {3.25ex plus 1ex minus .2ex}% before
  {0pt}% after

\begin{document}
\subsubsection{\sffamily A brand new template}Until now, we have have been using
a combination of markdown and pandoc for producing both the draft and the final
version of an article.

\noindent \textbf{\sffamily A brand new template ---} Until now, we have have
been using a combination of markdown and pandoc for producing both the draft
and the final version of an article.

\subsubsection{\sffamily A brand new template}Until now, ...

\noindent \textbf{\sffamily A brand new template ---} Until now, ...
\end{document}

enter image description here

You could also load package microtype:

enter image description here

5

It mostly depends if you want the spaces around the dash to participate to line stretch/shrink or not.

You also need to remove the space normally added after the title, which can be done with \titlespacing. You find the standard parameters at the end of section 9.2 in the documentation of titlesec; for \subsubsection it is

\titlespacing*{\subsubsection}{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}

The parameters are

  1. indentation (you want it to stay zero)
  2. vertical space before the title (you want it the same)
  3. horizontal space after the title (you want it to be zero)

The difference between \titlespacing and \titlespacing* is irrelevant for run-in titles. For block titles, the latter kills the indentation of the following paragraph.

If you want the spaces not to participate in stretching/shrinking:

\documentclass[12pt]{article}
\usepackage{lipsum, titlesec}

\titleformat{\subsubsection}[runin]
  {\normalfont\sffamily\bfseries}
  {}
  {0em}
  {}
  [\mbox{ --- }]
\titlespacing*{\subsubsection}{0pt}{3.25ex plus 1ex minus .2ex}{0pt}

\begin{document}

\subsubsection{A brand new template}
Until now, we have have been using a combination of markdown and
pandoc for producing both the draft and the final version of an article.

\noindent\textbf{\sffamily A brand new template\mbox{ --- }}%
Until now, we have have been using a combination of markdown and
pandoc for producing both the draft and the final version of an article.

\end{document}

enter image description here

If you want instead that the spaces participate in stretching and shrinking:

\documentclass[12pt]{article}
\usepackage{lipsum, titlesec}

\titleformat{\subsubsection}[runin]
  {\normalfont\sffamily\bfseries}
  {}
  {0em}
  {}
  [ --- \hspace*{0pt}]
\titlespacing*{\subsubsection}{0pt}{3.25ex plus 1ex minus .2ex}{0pt}

\begin{document}

\subsubsection{A brand new template}
Until now, we have have been using a combination of markdown and
pandoc for producing both the draft and the final version of an article.

\noindent\textbf{\sffamily A brand new template --- }%
Until now, we have have been using a combination of markdown and
pandoc for producing both the draft and the final version of an article.

\end{document}

With \hspace*{0pt} we ensure the space after the dash is not removed.

enter image description here

2

Hopefully this should be close to what you want. I used the short syntax for the spacing before the subsubsection title:

\documentclass[12pt]{article}
\usepackage{lipsum, titlesec}
\usepackage{lipsum}

\titleformat{\subsubsection}[runin]
            {\normalfont\sffamily\bfseries}{}{-0.2em}{}[ --- ]

\titlespacing{\subsubsection}{0pt}{*3.2}{0.25em}

\begin{document}

\lipsum[2]

\subsubsection{A brand new template} Until now, we have have been using
a combination of markdown and pandoc for producing both the draft and the final
version of an article.\\

\noindent \textbf{\sffamily A brand new template ---} Until now, we have have
been using a combination of markdown and pandoc for producing both the draft
and the final version of an article.

\end{document} 

enter image description here

You must log in to answer this question.

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