[Tex/LaTex] Totally sweet horizontal rules in LaTeX

decorationsrules

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?

Best Answer

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.

Related Question