1

I would like to change the appearance of \paragraph{} (particularly the space between the end of the heading and the beginning of the text) to look more like

\noindent\textbf{Paragraph heading} --- Lorem ipsum dolor

I have been googling for an hour, and I found all sort of ways for changing the spaces around the heading, but I could not find how to append something to it.

NOTE: The three dashes are supposed to be turned into an em-dash, they are not there to signify white space. Sorry if it was not clear the first time around.

  • Are those dashes supposed to represent a space or an em-dash? – Gonzalo Medina Aug 4 '15 at 16:56
  • They are supposed to be an em-dash. – Morpheu5 Aug 4 '15 at 16:59
  • I see. Then, please see my updated answer. – Gonzalo Medina Aug 4 '15 at 17:00
3

With the titlesec package:

\documentclass{article}
\usepackage{titlesec}

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

\begin{document} 

\paragraph{A test paragraph} Some test text

\end{document}

The result:

enter image description here

Without packages:

\documentclass{article}

\makeatletter
\renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}%
                                    {3.25ex \@plus1ex \@minus.2ex}%
                                    {-0.5em}%
                                    {\normalfont\normalsize\bfseries}}
\def\@sect#1#2#3#4#5#6[#7]#8{%
\ifnum #2>\c@secnumdepth
\let\@svsec\@empty
\else
\refstepcounter{#1}%
\protected@edef\@svsec{\@seccntformat{#1}\relax}%
\fi
\@tempskipa #5\relax
\ifdim \@tempskipa>\z@
\begingroup
#6{%
\@hangfrom{\hskip #3\relax\@svsec}%
\interlinepenalty \@M #8\@@par}%
\endgroup
\csname #1mark\endcsname{#7}%
\addcontentsline{toc}{#1}{%
\ifnum #2>\c@secnumdepth \else
\protect\numberline{\csname the#1\endcsname}%
\fi
#7}%
\else
\def\@svsechd{%
#6{\hskip #3\relax
\@svsec #8}%
\csname #1mark\endcsname{#7}%
\addcontentsline{toc}{#1}{%
\ifnum #2>\c@secnumdepth \else
\protect\numberline{\csname the#1\endcsname}%
\fi
#7}}%
\fi
\@xsect{#5}
\ifnum#2=4\relax---\ \fi}
\makeatother

\begin{document} 

\paragraph{A test paragraph} Some test text

\end{document}
  • Looks good, thanks. Just one thing: the space to the left of the em-dash does not seem to stretch like the one to the right. – Morpheu5 Aug 4 '15 at 17:07
  • @Morpheu5 I don't quite understand. Do you mean the spaces are not equal? – Gonzalo Medina Aug 4 '15 at 17:14
  • Yes, I mean that. – Morpheu5 Aug 4 '15 at 17:14
  • Ah, I added a \hspace{.5em} before the ~--- and it looks good now. Are those spaces supposed to stretch at all? – Morpheu5 Aug 4 '15 at 17:16
  • 1
    @Morpheu5 I introduced the same modification in my updated answer. – Gonzalo Medina Aug 4 '15 at 17:22
0

How about

\newcommand[1]{\mypar}{\paragraph{#1}\hspace{3em}}

or

\newcommand[1]{\mypar}{\paragraph{#1}~---}
  • Sorry, I thought it was clear that the '---' were supposed to be an em-dash. – Morpheu5 Aug 4 '15 at 17:00
  • 2
    I'll update my answer for the sake of completeness. However, Gonzalo's way is much better than mine. – Philipp Imhof Aug 4 '15 at 17:35

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.