Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am writing paragraphs that seldom require titles. I'd like the paragraph name to be separated from the actual content with a symbol. It can be an hyphen or whatever. My issue is if I type:

\paragraph*{My great title -} My fantastic content goes here.

there is way too much space between the hyphen and the content and similarly if I type:

\paragraph*{My great title} - My fantastic content goes here.

Is there a way to let the hyphen to nicely plump in the middle?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

In the default article document class, \paragraph leaves a gap of 1em in the prevailing font (\normalfont\normalsize\bfseries). So, using

\paragraph*{My great title}{\bfseries\hspace{-1em}}~-~My fantastic content goes here.

would yield equivalent spacing of a non-breaking space around the hyphen -. Of course, you could replace that with whatever length you're interested in. Here's a small example:

enter image description here

\documentclass{article}
\newcommand{\parhyphen}[1][1em]{% Symmetric \paragraph hyphen
  {\normalfont\normalsize\bfseries\hspace*{-1em}}\hspace*{#1}-\hspace*{#1}\ignorespaces}
\begin{document}
\paragraph*{My great title} - My fantastic content goes here.

\paragraph*{My great title -} My fantastic content goes here.

\paragraph*{My great title}\parhyphen[2em]My fantastic content goes here.

\paragraph*{My great title}\parhyphen[30pt]My fantastic content goes here.
\end{document}

\parhyphen[<len>] inserts a paragraph hyphen of length <len> (defaults to 1em in \normalfont).


It would be possible to redefine \paragraph and insert this dash in a manual fashion using, for example:

\makeatletter
\renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}%
                                    {3.25ex \@plus1ex \@minus.2ex}%
                                    {0pt}%
                                    {\normalfont\normalsize\bfseries}}
\makeatother

in your document preamble. Then you could use

\paragraph*{My great title} \mbox{} - My fantastic content goes here.
share|improve this answer
    
I am a pretty basic LaTeX user, hope you don't mind me asking is there a way to avoid repeating all this markup, maybe override the \paragraph{} command? –  haunted85 Mar 22 '13 at 18:05
    
@haunted85: This could be done using a package like titlesec. Do all of your \paragraphs have this dash? –  Werner Mar 22 '13 at 18:07
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.