175

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?

9
  • 10
    call me old-fashioned, but is "totally sweet" the adjective you're really looking for here?
    – nickf
    Commented Feb 6, 2009 at 16:23
  • 32
    Old-fashioned, nick. :-P
    – JMD
    Commented Feb 6, 2009 at 16:26
  • 10
    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
    Commented Feb 6, 2009 at 16:42
  • 65
    \usepackage{totallysweetrules}
    – quant_dev
    Commented Dec 7, 2009 at 10:15
  • 4
    This question might be relevant too.
    – ienissei
    Commented Mar 30, 2012 at 9:09

14 Answers 14

103

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.

0
43

In general:

\rule{width}{height}

macro:

\newcommand{\sectionline}{%
  \nointerlineskip \vspace{\baselineskip}%
  \hspace{\fill}\rule{0.5\linewidth}{.7pt}\hspace{\fill}%
  \par\nointerlineskip \vspace{\baselineskip}
}
3
  • 5
    Removing the %s from the macro made it center the line properly.
    – Matt
    Commented Sep 3, 2011 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
    Commented Aug 31, 2012 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
    Commented Jun 7, 2013 at 16:45
37

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

1
  • 3
    Forgive me if I am overlooking something, but I don't see you calling any package named web-0-mint!
    – Ludi
    Commented Jul 20, 2017 at 16:34
30

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}
1
  • 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.
    – yo'
    Commented Oct 13, 2012 at 20:55
24

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.

3
  • 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? Commented Nov 5, 2011 at 23:47
  • 2
    @FgNu That sounds like a new question...
    – Seamus
    Commented Nov 6, 2011 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. Commented Oct 13, 2012 at 7:25
22

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}
3
  • Cf. my comment on dreamlax's post, below. Commented Dec 7, 2009 at 9:49
  • i get this error: ! Missing \endcsname inserted. <to be read again> \unhbox ? I have no idea why?
    – Andreas
    Commented Dec 17, 2009 at 10:13
  • In which implementation you can provide the filename with the extension on?
    – mike3996
    Commented Sep 2, 2010 at 17:32
15

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}
1
  • This works for me, but not with the command shown (xfilll) nor with the one in the package's documentation (xfill). What worked was what's given as a comment under Usage in xhfill.sty: \xhrulefill{blue}{5pt}.
    – Liam
    Commented Dec 26, 2015 at 20:55
13

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.

9

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.

1
  • 1
    @jasedit I tried to resolve the bedknobs issue, but realized my hands were handcuffed to them. Commented May 22, 2013 at 20:23
9

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).

1
  • 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. Commented Dec 7, 2009 at 9:45
7

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.

1
  • 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
    Commented Oct 25, 2011 at 21:28
7

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.

4

I use the dingbats that come with Minion like so:

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

4

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.


2
  • 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. Commented Dec 7, 2009 at 9:48
  • 2
    The link is dead, making the answer completely useless. Flagging as “not an answer”. Commented Feb 8, 2019 at 4:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .