24

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

  • 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 8 '10 at 8:12
19

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 7 '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 8 '10 at 4: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 9 '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) – Schneider Dec 30 '16 at 17:58
13

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

example

  • 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 7 '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 7 '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 9 '10 at 17:49
9

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

\paragraph ~\\

Source for the answer

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.

  • 1
    Welcome! Very hacky ... – Mensch Nov 21 '15 at 19:49
3

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}
  • Works nice with memoir document class. – djnavas Aug 26 '17 at 8:40
  • This integrates well with LyX, as the wysiwym structure remains untouched. Just put the renewcommand part in the preamble. – Samufi May 22 at 17:58
2

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

\paragraph{something}\hfill

The double newline above is probably required.
  • This does not work for me. – user1511417 Aug 5 '17 at 11:19
  • this solution works better than: \paragraph ~\\ because it does not break the paragraph!!! – berto May 22 at 20:36

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.