21

I'm writing a document that contains a rather deep tree of nested lists, and was wondering if how I would go about reformatting the \paragraph macro to format the text contained within it as a \section, specifically by separating the title from the body and placing it above the body. I've encountered the titlesec package but I'm confused as to how to use it since it seems to be used very little so there are very few examples to follow.


Update 1: I'm using the article document class.

3
  • 1
    Which document class are you using? \paragraph and \section are macros of the class (or a package) and their implementation can be different depending on the class.
    – Stefan Kottwitz
    Oct 7, 2010 at 20:55
  • Iirc, the LaTeX Companion has a section dedicated to titlesec (my copy is a few thousand kilometers away, so I can’t check).
    – Caramdir
    Oct 7, 2010 at 22:21
  • I'm using the article documentclass. I've updated the question to reflect this.
    – user1332
    Oct 8, 2010 at 10:18

2 Answers 2

17

Pages 26-27 of the titlesec documentation show "how [the] sectioning commands of the standard classes could be defined" using titlesec commands. Take the definition of \paragraph and change the optional "format" argument of \titleformat from runin to hang (or drop it entirely).

\documentclass{article}

\usepackage{titlesec}
\titleformat{\paragraph}[hang]{\normalfont\normalsize\bfseries}{\theparagraph}{1em}{}
\titlespacing*{\paragraph}{0pt}{3.25ex plus 1ex minus .2ex}{1em}

\begin{document}

\paragraph{A paragraph}

Some text.

\end{document}

EDIT: To make a \paragraph look exactly like a \section in the article class, use

\titleformat{\paragraph}{\normalfont\Large\bfseries}{\theparagraph}{1em}{}
\titlespacing*{\paragraph}{0pt}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}

3

This FAQ answer talks about defining a \subsubsubsection, if that is what you are looking for, and recommends either titlesec or reading the latex sources to understand the usage of \@startsection.

I get the impression that titlesec is used quite a bit, mostly in professional book production so you are unlikely to see many worked examples, beyond the ones in the titlesec manual.

You must log in to answer this question.