41

I want to format paragraph to work as a regular title

\paragraph{title} text goes here

output of that is:

title text goes here


how can I change the output to force line break and use the usal indentation of 1st line?

title

text goes here

__

edit1: this is for a thesis and I'm using the document class - book. I don't want to use \subsubsection because this is the structure of the document. I just simply need one level of headers deeper.

And that is why I wanted to use \paragraph as a heading not as paragraph.

edit2: clarification: I'd like paragraph to behave like a header like section subsection subsubsection etc

lockstep
  • 250,273
Splashy
  • 5,915
  • The code in my answer also works for the »book« class. You may need an additional \setcounter{secnumdepth}{3} in the preamble to number subsubsections. If you also want numbered paragraphs, you will need \setcounter{secnumdepth}{4}. – Thorsten Donig Nov 08 '10 at 08:12

9 Answers9

37

You didn't say anything about your document class. So, here comes an example for article that uses the titlesec package.

\documentclass[11pt,a4paper,english]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage[raggedright]{titlesec}
\usepackage{blindtext}

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

\begin{document}
  \blinddocument
\end{document}

You can easily adjust the space before and after the heading according to your needs. The package manual has the details. The package also masters page styles so that it might not be necessary to load fancyhdr.

Note that the blindtext package is only used for creating dummy text thus not part of the solution.

  • I didn’t know about blindtext. Quite useful for testing! – Caramdir Nov 07 '10 at 17:13
  • @Caramdir: There's something about the text used in blindtext that drives me nuts. It is good for testing document structure though. – TH. Nov 08 '10 at 04:45
  • thumbs up for blindtext! it's great for testing!

    So using it, i know I got Just what I wanted!! THANK YOU so much!

    – Splashy Nov 09 '10 at 17:45
  • I found that the raggedright option to titlesec can be omitted. Also, one should not combine this with the redefinition of \paragraph in the second approach in this answer (where \subsubsubsection is defined) – Bart Michels Dec 30 '16 at 17:58
16

With the default settings, your request would render exactly like a \subsubsection*, so maybe you could just use that instead of \paragraph?

example

Caramdir
  • 89,023
  • 26
  • 255
  • 291
  • 2
    One could also use \subsubsection (the non-starred variant) and add \setcounter{secnumdepth}{2} to the preamble (the default value for the article class is 3). – lockstep Nov 07 '10 at 17:23
  • Has also been my first idea because it is simple. But probably the vertical distance between heading and first paragraph is too big and it can't be adjusted. – Thorsten Donig Nov 07 '10 at 18:02
  • this is idea is simple and is what I had in mind in case i would not solve the issue in any other way. Besides what Thorsten said the problem with this is also the impossibility to use subsubsection in toc and not subsubsection*. Although in toc that would not be a problem it could be tricky in minitoc where you tend to use higher setcounters. (I'm hope i was clear on this last comment) – Splashy Nov 09 '10 at 17:49
15

I have seen many hacks for this, including \mbox{} and other approaches but this one is the most convenient!

\paragraph ~\\

Source for the answer

Shubham Sharma
  • 251
  • 2
  • 4
6

For me works with (without titlesec):

\documentclass{article}

    \makeatletter
    \renewcommand\paragraph{%
        \@startsection{paragraph}{4}{0mm}%
           {-\baselineskip}%
           {.5\baselineskip}%
           {\normalfont\normalsize\bfseries}}
    \makeatother

    \begin{document}

    \paragraph{A paragraph}
    My text

    \end{document}
3

This seems like the least hacky approach:

\documentclass{article}
\begin{document}
\paragraph*{Some title stuff}\leavevmode\\
blah blah blah
\end{document}

It tests OK with \documentclass{report|book} too.

The * in \paragraph*{} is not essential; it just keeps the heading out of a Table of Contents.

If you want the text indented, you can add a blank line instead of \\.

I got the idea for this from a similar solution to the problem of adding a line break after the label of an item in the description environment.

3

Another hacky but easy to understand approach is simply filling the line:

\paragraph{something}\hfill

The double newline above is probably required.
2

To let a paragraph behave the most like a subsubsubsection (i.e. a parskip between it and the text instead of a whole line), add an mbox, but do break the line with \\. Instead, leave a blank line, like you normally would.

\paragraph{title}\mbox{}

text goes here
R. Bosman
  • 121
  • 1
  • 1
  • 4
1

If you are writing your thesis in double column, then using ~\\ doesn't work.

I found, the best solution for me in this case was,

\paragraph{title} ~\linebreak

text

The \mbox{} technique also works, if you add a \linebreak after \mbox{}.

TeXnician
  • 33,589
panda
  • 11
1

If you're using a KomaScript class, titlesec will not work.

KomaScript provides commands to do what you would otherwise use titlesec to do:

Adjusting spacing around section/subsection titles with koma-script

KOMA-Script version 3.26 introduces two new keys to \RedeclareSectionCommand and \RedeclareSectionCommands: runin and afterindent. Possible values for both keys are bysign, true and false.

So you could do something like:

\RedeclareSectionCommands[
    beforeskip=.75\baselineskip plus 1ex minus -0.2ex,
    runin=false,
    afterskip=0.33\baselineskip,
    font=\bfseries,
    afterindent=false
]{paragraph,subparagraph}