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 have been trying to find a way to easily drop a nice horizontal rule into a LaTeX document. \hline just makes a line across the page. It would seem that some package must provide something that is maybe half a page wide, with little bedknobs on the ends or something to act as a nice section marker for paragraphs.

Any ideas? Or am I boned, and need to come up with my own macro to create such a beast?

share|improve this question

migrated from stackoverflow.com Oct 25 '11 at 20:33

This question came from our site for professional and enthusiast programmers.

6  
call me old-fashioned, but is "totally sweet" the adjective you're really looking for here? –  nickf Feb 6 '09 at 16:23
22  
Old-fashioned, nick. :-P –  JMD Feb 6 '09 at 16:26
3  
It is the adjective I'm looking for. Something like ----, where the asterisks are cool leaves or something, like a big fancy curtainrod. If someone saw it, they would exclaim, "TOTALLY SWEET!" –  Arcane Feb 6 '09 at 16:42
45  
\usepackage{totallysweetrules} –  quant_dev Dec 7 '09 at 10:15
4  
This question might be relevant too. –  ienissei Mar 30 '12 at 9:09

14 Answers 14

In general:

\rule{width}{height}

macro:

\newcommand{\sectionline}{%
  \nointerlineskip \vspace{\baselineskip}%
  \hspace{\fill}\rule{0.5\linewidth}{.7pt}\hspace{\fill}%
  \par\nointerlineskip \vspace{\baselineskip}
}
share|improve this answer
1  
Removing the %s from the macro made it center the line properly. –  Matt Sep 3 '11 at 16:56
1  
For other users: don't forget that "width" and "height" are in terms of "pt", so the proper usage of \rule is something along the lines of \rule{500pt}{1pt}. –  rsegal Aug 31 '12 at 15:32
    
I was trying to use this to get a double rule... but this doesn't work. Could you help me to understand why. \newcommand{\sectionline}{ \nointerlineskip \vspace{\baselineskip} \hspace{\fill}\rule{0.95\linewidth}{.7pt} \rule{0.95\linewidth}{1.7pt}\hspace{\fill} \par\nointerlineskip \vspace{\baselineskip} } –  theobear Jun 7 '13 at 16:45

Everything I've ever read defines a custom command for fancy graphical paragraph separators. Nothing in latex adds bedknobs or any fancy decorations, and I can't find any packages which add such functionality.

The example I've seen is typically:

\newcommand{\parasep}{\begin{center}*\hspace{6em}*\hspace{6em}*\end{center}}

Obviously from here you could replace the asterisks with something more visually appealing.

share|improve this answer
    
@jasedit I tried to resolve the bedknobs issue, but realized my hands were handcuffed to them. –  Nicholas Hamilton May 22 '13 at 20:23

You might try perusing some font collections. Here are some free examples; if you're willing to pay a little money or do some work on your own, you can get some really nice ones.


share|improve this answer
    
Fonts are the way to go, but the typoasis fonts are just raw foundries, and so don't integrate very well with tex. See my comment below. –  Charles Stewart Dec 7 '09 at 9:48

I used this image and then this code:

enter image description here

In header:

\newcommand{\parasep}{
\begin{center} 
   \includegraphics[scale=.5]{hrule.png} 
\end{center}}

In body where you want the image:

\parasep

Oh and remember to:

\usepackage{graphicx}
share|improve this answer
    
Cf. my comment on dreamlax's post, below. –  Charles Stewart Dec 7 '09 at 9:49
    
i get this error: ! Missing \endcsname inserted. <to be read again> \unhbox ? I have no idea why? –  Andreas Dec 17 '09 at 10:13
    
In which implementation you can provide the filename with the extension on? –  progo Sep 2 '10 at 17:32

In TeX, there is a primitive command \leaders which is able to take an hbox and replicate it as many times as necessary to fill a specific amount of glue (which can be the entire with of the page if necessary). Each box that it lays down will stick to a vertical grid, so that boxes laid directly below will be in-line with the ones above (so they don't appear out of sync). This technique is commonly used for tables of contents.

You can supply your own custom graphic and box to have a repeating pattern used as a line.

\usepackage{graphicx}

\newcommand{\nicehline}{%
    \par\noindent
    \leaders\hbox to 1in{\includegraphics{somethingnice.png}}\hfill
    \par
}

Lorem ipsum dolor sit amet.

\nicehline

Lorem ipsum dolor sit amet.

Of course, you'll need to supply your own somethingnice.png, or alternatively use a dingbat. Perhaps it may be better to save the graphic into its own box register if it will mean the graphics are only included once and referenced thereafter (as opposed to included each time it is to be displayed).

share|improve this answer
    
This is basically the right way to do it, but using metafont/metapost pictures as fonts may give better results than embedding png/eps/&c graphics, since they will scale well. –  Charles Stewart Dec 7 '09 at 9:45

memoir document class has facilities to draw these "totally sweet" anonymous breaks. See section 6.7 Fancy anonymous breaks (page 109-111) of the manual for details.

share|improve this answer
    
Hi @Seamus, I looked at the Memoir class and it does seem to have beautiful separators. How would I go about importing some of these if I were to use another document class? –  fg nu Nov 5 '11 at 23:47
2  
@FgNu That sounds like a new question... –  Seamus Nov 6 '11 at 21:26
1  
I changed the manual reference to include the section name, as the page count had changed a little in newer version (the one I have is dated 2011/03/06). I assume that was the section you were referring to. –  Torbjørn T. Oct 13 '12 at 7:25

Just to reiterate: you can get better results with fonts than embedded images, and better results with TeX-native font representations (e.g., MetaFont), than with TrueType fonts.

Noah, above, linked to typoasis, which has some mouthwateringly beautiful fonts, but they are alien to TeX, so you might not get ideal results with them.

Zapfino, Hermann Zapf's calligraphic font, is worth a look: Zapf worked with Knuth on this, and some other, fonts, so it is all done The Right Way.

If you do make use of TeX-alien fonts, it is best to import tham as MetaType1 fonts using, say, the pf2mt1 utility; cf. the CTAN metatype1 package's README for some info.

share|improve this answer
    
1) Couldn't you use a vector-image for nice results? I know that LaTeX doesn't support actual image formats like SVG, but you can put a vector image in a PDF then import that. 2) An alternative to non-TeX fonts would be LuaTeX or XeTeX, wouldn't it? I'm not a user of either, but I've heard good things about LuaTeX. –  Canageek Oct 25 '11 at 21:28

Just to chime in with a font suggestion: if you do go down that path, the fourier-orns package loads a lot of nice ornaments that, as the name suggests, are designed to go with Fourier. See the fourier documentation for details.

share|improve this answer

I use the dingbats that come with Minion like so:

\newcommand\anonbreak{\fancybreak{\reflectbox{\char"E0B6} \quad \char"E0BE \quad \char"E0B6}\vspace{\baselineskip}}

share|improve this answer

The xhfill package provides an array of leaders and colours to create straight-forward, sweet rules. The following is taken mostly from the xhfill documentation:

enter image description here

\documentclass{article}
\usepackage{listings}% http://ctan.org/pkg/listings
\lstset{language=[LaTeX]TeX,
  basicstyle=\small\ttfamily}
%\usepackage{xcolor}% http://ctan.org/pkg/xcolor | Loaded by listings
\usepackage{xhfill}% http://ctan.org/pkg/xhfill

\setlength{\parindent}{0pt}% Just for this example
\newcommand{\xfill}[2][1ex]{{%
  \dimen0=#2\advance\dimen0 by #1
  \leaders\hrule height \dimen0 depth -#1\hfill%
}}
\newcommand{\xfilll}[2][1ex]{%
  \dimen0=#2\advance\dimen0 by #1%
  \leaders\hrule height \dimen0 depth -#1\hfill%
}

\begin{document}
blah\xfilll{1pt}blub
\begin{lstlisting}
blah\xfilll{1pt}blub
\end{lstlisting}
\bigskip

blah\xfilll[0pt]{4pt}blub
\begin{lstlisting}
blah\xfilll[0pt]{4pt}blub
\end{lstlisting}
\bigskip

blah\xfilll[-12pt]{12pt}blub
\begin{lstlisting}
blah\xfilll[-12pt]{12pt}blub
\end{lstlisting}
\bigskip

blah\xrfill{1pt}[blue]blub blah\xrfill{2pt}[cyan]blub
\begin{lstlisting}
blah\xrfill{1pt}[blue]blub blah\xrfill{2pt}[cyan]blub
\end{lstlisting}
\bigskip

laber\xrfill[0pt]{4pt}[green]blub blub
\begin{lstlisting}
laber\xrfill[0pt]{4pt}[green]blub blub
\end{lstlisting}
\bigskip

blah\xrfill[-1ex]{1pt}[red]blub
\begin{lstlisting}
blah\xrfill[-1ex]{1pt}[red]blub
\end{lstlisting}
\bigskip

blah \xhrulefill{cyan}{1cm} blub
\begin{lstlisting}
blah \xhrulefill{cyan}{1cm} blub
\end{lstlisting}
\bigskip

blah \xhrectanglefill{0.5cm}{1pt} blubber
\begin{lstlisting}
blah \xhrectanglefill{0.5cm}{1pt} blubber
\end{lstlisting}
\bigskip

blah\xdotfill{1pt}[blue]blah\xdotfill{2pt}[red]blub
\begin{lstlisting}
blah\xdotfill{1pt}[blue]blah\xdotfill{2pt}[red]blub
\end{lstlisting}
\end{document}
share|improve this answer

You might want to install the webomint fonsts from CTAN. There are a lot of ornaments in this font. Then one possibility would be:

\documentclass[11pt]{article}
\usepackage{graphicx}
\usepackage{lipsum}

\makeatletter
\newcommand{\EnglischeLinie}{%
  \@afterindentfalse
  {\begin{center}
    \resizebox{0.8\linewidth}{0.4ex}{{%
        \fontsize{20}{24}\usefont{U}{webo}{xl}{n}{4}}}%
  \end{center}}\@afterheading}
\makeatother

\begin{document}
\lipsum[1]
\EnglischeLinie
\lipsum[1]
\end{document}

This will look like this:

enter image description here

You may play around with this.

share|improve this answer

Well, we can always appeal to tikz to make these graphic details.

Below you can see some lines with the tikz own endings.

Tikz arrow tips

And the picture above was generated from the following code:

\documentclass[a4paper, twocolumn]{article}

\usepackage{tikz}
\usetikzlibrary{arrows}

\newcommand{\myrule} [3] []{
    \begin{center}
        \begin{tikzpicture}
            \draw[#2-#3, ultra thick, #1] (0,0) to (0.5\linewidth,0);
        \end{tikzpicture}
    \end{center}
}

\begin{document}

    \myrule{}{}
    \myrule[double]{}{}
    \myrule{to}{to}
    \myrule[double]{to}{to}
    \myrule{to reversed}{to reversed}
    \myrule[double]{to reversed}{to reversed}
    \myrule{implies}{implies} 
    \myrule[double]{implies}{implies}
    \myrule{latex}{latex}
    \myrule{latex reversed}{latex reversed}
    \myrule{latex'}{latex'}
    \myrule{latex' reversed}{latex' reversed}
    \myrule{stealth}{stealth}
    \myrule{stealth reversed}{stealth reversed}
    \myrule{stealth'}{stealth'}
    \myrule{stealth' reversed}{stealth' reversed}
    \myrule{triangle 90}{triangle 90}
    \myrule{triangle 90 reversed}{triangle 90 reversed}
    \myrule{triangle 60}{triangle 60}
    \myrule{triangle 60 reversed}{triangle 60 reversed}
    \myrule{triangle 45}{triangle 45}
\myrule{triangle 45 reversed}{triangle 45 reversed}
    \myrule{open triangle 90}{open triangle 90}
    \myrule{open triangle 90 reversed}{open triangle 90 reversed}
    \myrule{open triangle 60}{open triangle 60}
    \myrule{open triangle 60 reversed}{open triangle 60 reversed}
    \myrule{open triangle 45}{open triangle 45}
    \myrule{open triangle 45 reversed}{open triangle 45 reversed}
    \myrule{angle 90}{angle 90}
    \myrule{angle 90 reversed}{angle 90 reversed}
    \myrule{angle 60}{angle 60}
    \myrule{angle 60 reversed}{angle 60 reversed}
    \myrule{angle 45}{angle 45}
    \myrule{angle 45 reversed}{angle 45 reversed}
    \myrule{hooks}{hooks}
    \myrule{hooks reversed}{hooks reversed}
    \myrule{(}{)}
    \myrule{)}{(}
    \myrule{|}{|}
    \myrule{o}{o}
    \myrule{*}{*}
    \myrule{diamond}{diamond}
    \myrule{open diamond}{open diamond}
    \myrule{square}{square}
    \myrule{open square}{open square}
    \myrule{serif cm}{serif cm}
    \myrule{left to}{left to}
    \myrule{left to reversed}{left to reversed}
    \myrule{right to}{right to}
    \myrule{right to reversed}{right to reversed}
    \myrule{left hook}{left hook}
    \myrule{left hook reversed}{left hook reversed}
    \myrule{right hook}{right hook}
    \myrule{right hook reversed}{right hook reversed}
    \myrule[line width = 2mm]{round cap}{round cap}
    \myrule[line width = 2mm]{butt cap}{butt cap}
    \myrule[line width = 2mm]{triangle 90 cap}{triangle 90 cap}
    \myrule[line width = 2mm]{triangle 90 cap reversed}{triangle 90 cap reversed}
    \myrule[line width = 2mm]{fast cap}{fast cap}
    \myrule[line width = 2mm]{fast cap reversed}{fast cap reversed}

\end{document}

But you can also use more powerful features:

Other resources

And to generate the image above:

\documentclass[a4paper, twocolumn]{article}

\usepackage{tikz}
\usetikzlibrary{decorations.markings}
\usetikzlibrary{decorations.shapes}
\usetikzlibrary{shapes.geometric}
\usetikzlibrary{decorations.fractals}
\usetikzlibrary{decorations.footprints}

\tikzset {
    , bedknobs one/.style = {
        decorate
        , fill = red!50
        , decoration = {
            shape backgrounds
            , shape = #1
            , shape size = 2mm
        }
    }
    , bedknobs two/.style = {
        decorate
        , decoration = {
            #1
        }
        , fill = blue!50
    }
}

\newcommand{\bedknobsone}[1]{
    \begin{center}
        \tikz \draw [bedknobs one = {#1}] (0,0) to (0.5\linewidth, 0);
    \end{center}
}

\newcommand{\bedknobstwo}[1]{
    \begin{center}
        \tikz \draw [bedknobs two = {#1}] (0,0) to (0.5\linewidth, 0);
    \end{center}
}

\newcommand{\bedknobsthree}[1]{
    \begin{center}
        \tikz [
            decoration = #1
        ] \draw decorate{ decorate{ decorate{ (0, 0) -- (0.5\linewidth, 0) }}};
    \end{center}
}

\newcommand{\bedknobsfour}{
    \begin{center}
        \begin{tikzpicture} [thick]
            \node[minimum size = 5mm] (first) {};
            \node[minimum size = 5mm, anchor = west] (second) at (first.east) {};
            \draw plot [smooth] coordinates {
                (first.north) (first.west) (first.south)
                (second.north) (second.east) (second.south)
            };
        \end{tikzpicture}
    \end{center}
}

\newcommand{\bedknobsfive}{
    \begin{center}
        \begin{tikzpicture} [thick]
            \node[minimum size = 5mm] (first) {};
            \node[minimum size = 5mm, anchor = west] (second) at (first.east) {};
            \node[minimum size = 5mm, anchor = west] (space) at (second.east) {};
            \node[minimum size = 5mm, anchor = west] (third) at (space.east) {};
            \node[minimum size = 5mm, anchor = west] (fourth) at (third.east) {};
            \draw plot [smooth] coordinates {
                (first.north) (first.west) (first.south)
                (second.north) (second.east) (second.south)
            };
            \draw plot [smooth] coordinates {
                (fourth.north) (fourth.east) (fourth.south)
                (third.north) (third.west) (third.south)
        };
        \end{tikzpicture}        
    \end{center}
}

\begin{document}

    \section {basic}

        \bedknobstwo{crosses}            
        \bedknobstwo{triangles}


    \section {shapes}

        \bedknobsone{dart}
        \bedknobsone{diamond}
        \bedknobsone{isosceles triangle}
        \bedknobsone{star}
        \bedknobstwo{shape backgrounds, shape scaled, shape start size=2.5mm,shape end size=1mm}


    \section {footprints}

        \bedknobstwo{footprints}
        \bedknobstwo{footprints, foot of = gnome}
        \bedknobstwo{footprints, foot of = bird}     
        \bedknobstwo{footprints, foot of = felis silvestri}


    \section {fractals}

        \bedknobsthree {Koch curve type 1}
        \bedknobsthree {Koch curve type 2}
        \bedknobsthree {Koch snowflake}
        \bedknobsthree {Cantor set}


    \section {Others}

        \bedknobsfour
        \bedknobsfive

\end{document}
share|improve this answer
3  
Just a note that it might be a good idea to externalize such things if you use them a lot, because TikZ is slowing the compilation a lot. –  tohecz Oct 13 '12 at 20:55

You may be interested in pgfornament.

\PassOptionsToPackage{svgnames}{xcolor}
\documentclass[11pt]{article}
\usepackage[object=vectorian]{pgfornament} %%  http://altermundus.com/pages/tkz/ornament/index.html
\usepackage{lipsum,tikz}

\newcommand{\sectionline}{%
  \noindent
  \begin{center}
  {\color{DarkViolet}
    \resizebox{0.5\linewidth}{1ex}
    {{%
    {\begin{tikzpicture}
    \node  (C) at (0,0) {};
    \node (D) at (9,0) {};
    \path (C) to [ornament=85] (D);
    \end{tikzpicture}}}}}%
    \end{center}
  }
%% A macro with two arguments to change ornaments and colors easily
%% Syntax -- \sectionlinetwo{<color>}{<ornament>}
\newcommand{\sectionlinetwo}[2]{%
  \nointerlineskip \vspace{.5\baselineskip}\hspace{\fill}
  {\color{#1}
    \resizebox{0.5\linewidth}{2ex}
    {{%
    {\begin{tikzpicture}
    \node  (C) at (0,0) {};
    \node (D) at (9,0) {};
    \path (C) to [ornament=#2] (D);
    \end{tikzpicture}}}}}%
    \hspace{\fill}
    \par\nointerlineskip \vspace{.5\baselineskip}
  }

\begin{document}
\lipsum[1]
\sectionline
\lipsum[2]
\sectionlinetwo{magenta}{84}
\lipsum[3]
\sectionlinetwo{DarkGreen}{88}
\end{document}

enter image description here

As pointed by Gonzalo, pgfornaments can be used without tikzpicture environment as

\newcommand{\sectionlinetwo}[2]{%
  \nointerlineskip \vspace{.5\baselineskip}\hspace{\fill}
  {\resizebox{0.5\linewidth}{1.2ex}
    {\pgfornament[color = #1]{#2}
    }}%
    \hspace{\fill}
    \par\nointerlineskip \vspace{.5\baselineskip}
  }

hence making code less cluttered.

share|improve this answer

The web-O-mints package offers here another option; a little example:

\documentclass[12pt]{article}
\usepackage[vmargin=2.5cm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{fourier}
\usepackage[nopar]{lipsum}

\newcommand\deco[2]{%
  \par\vspace{1ex}
  \begin{center}
  \fontsize{#1}{#1}\usefont{U}{webo}{xl}{n}#2
  \end{center}
  \vspace*{1ex}\par
}

\newcounter{mytimes}
\newcommand\OPpattern{%
\loop
\ifnum\value{mytimes}<7\relax
\stepcounter{mytimes}%
\rotatebox{90}{o}\raisebox{8pt}{\rotatebox{270}{n}}%
\repeat}

\begin{document}

\lipsum[2] 
\deco{10pt}{IJKLIJKL}
\lipsum[2] 
\deco{16pt}{[][][][][][]}
\lipsum[2] 
\deco{10pt}{pqpqpqpqpqpqpqpqpqpq}
\lipsum[2] 
\deco{10pt}{444444444}
\lipsum[2] 
\deco{10pt}{fgfgfgfgfgfgfg}
\lipsum[2] 
\deco{14pt}{\OPpattern}
\lipsum[2] 
\deco{12pt}{mmmmmmmmmmmmmm}
\lipsum[2] 

\end{document}

enter image description here

share|improve this answer

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.