4

I changed the format of subsubsection to remove the line breaks after them using titlesec package and the command

\titleformat{\subsubsection}[runin]{\normalfont\bfseries}{\thesubsubsection.}{3pt}{}

Complete code:

\documentclass{article}
\usepackage{titlesec}

\titleformat{\subsubsection}[runin]{\normalfont\bfseries}{\thesubsubsection.}{3pt}{}
\begin{document}

\section{Section one}
Some text
\subsection{Subsection one one}
Some text
\subsubsection{Subsubsection one one one}
This is subsubsection. Blah blah blah.

\end{document}

This produces the subsubsection title immediately followed by the body. Now, I want to add a colon (or dash) after the title. e.g.

1.1.1. Subsubsection one one one: This is subsubsection. Blah blah blah.

Is there a way to do this?

2
  • Welcome to TeX.SX! Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}.
    – Pier Paolo
    Mar 5, 2015 at 14:28
  • Added the working example.
    – CentAu
    Mar 5, 2015 at 14:40

2 Answers 2

4

Use the optional argument of titleformat meant for after code:

\titleformat{\subsubsection}[runin]{\normalfont\bfseries}{\thesubsubsection.}{3pt}{}[:]   %%<--- this one

Code:

\documentclass{article}
\usepackage{titlesec}

\titleformat{\subsubsection}[runin]{\normalfont\bfseries}{\thesubsubsection.}{3pt}{}[:]
\begin{document}

\section{Section one}
Some text
\subsection{Subsection one one}
Some text
\subsubsection{Subsubsection one one one}
This is subsubsection. Blah blah blah.

\end{document}

enter image description here

1

The other answer only works for some of the predefined shapes (for example, runin as in the question), but will fail in some cases (display, or block, see example at the bottom).

The proper way to do these kind of additions (see the titlesec documentation, Section 4.4. Putting a Dot after the Section Title, page 12) is to define a command with a mandatory argument to be used in the last argument for \titleformat. A little example:

\documentclass{article}
\usepackage{titlesec}

\newcommand\colonafter[1]{#1:}
\titleformat{\subsubsection}[runin]
  {\normalfont\bfseries}{\thesubsubsection.}{3pt}{\colonafter}

\begin{document}

\section{Section one}
Some text
\subsection{Subsection one one}
Some text
\subsubsection{Subsubsection one one one}
This is subsubsection. Blah blah blah.

\end{document}

enter image description here

As I already mentioned, the other answer's approach works in the OP's situation because the runin format was used, but the solution proposed there will fail for other shapes as this example shows:

\documentclass{article}
\usepackage{titlesec}

\titleformat{\subsubsection}[display]
  {\normalfont\bfseries}{\thesubsubsection.}{3pt}{}[:]

\begin{document}

\section{Section one}
Some text
\subsection{Subsection one one}
Some text
\subsubsection{Subsubsection one one one}
This is subsubsection. Blah blah blah.

\end{document}

Resulting in the wrong output:

enter image description here

You must log in to answer this question.

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