# Extending pgfornament's vector lines on the entire line width

There are nice looking ornaments for horizontal lines in pgfornament (see page 20 of this doc).

However, the length of the left and right straight parts of some of these ornaments is quite short. Looking at ornament 88, I ideally want something like this:

That is, having this ornament centered horizontally, where the left and right straight parts of the ornament are stretched to fill the rest of the line.

I have the following command to arrive to this result, using the xhfill package:

\documentclass{article}

\usepackage[object=vectorian]{pgfornament}
\usepackage{xhfill}
\usepackage{lipsum}

\newcommand{\separator}{%
{
\noindent\xhrulefill{black}{1.39pt}
\hspace{-13pt}
\raisebox{-2.95pt}{\resizebox{0.4\linewidth}{2ex}
{{
{\begin{tikzpicture}
\node  (C) at (0,0) {};
\node (D) at (6,0) {};
\path (C) to [ornament=88] (D);
\end{tikzpicture}}}}}}%
\hspace{-13pt}
\xhrulefill{black}{1.39pt}
}

\begin{document}

\separator

\lipsum[1]

\end{document}


This works OK as you can see, but it has some problems:

• Lines are superimposed on the ornament which leads to graphical bugs when viewing the PDF in pdf viewers, depending on the zooming level (a common problem).

• The width of the xhrulefill is not exactly right; I can see a very slight difference when printing this on a page. I can't seem to make it disappear no matter how close I get to the "correct" width.

• (this command's code is ugly, but that's a minor problem)

Is there a better way to do this?

It is probably best do all the drawing inside tikz. You can get the total width required from \textwidth.

\documentclass{article}

\usepackage[object=vectorian]{pgfornament}
\usetikzlibrary{calc}
\usepackage{lipsum}

\newcommand{\separator}{%
{\par\noindent
\begin{tikzpicture}\def\mylen{3cm}
\coordinate (A) at (0,0);
\coordinate (C) at (\mylen,0);
\coordinate (B) at (\textwidth,0);
\coordinate (D) at ($(\textwidth,0)-(\mylen,0)$);
\draw[line width=1.15pt,line cap=rect] ($(A)+.5*(1.15pt,0)$) -- (C) (D) -- ($(B)-.5*(1.15pt,0)$);
\path (C) to[ornament=88, options/.append style={yshift=.52pt}] (D);
\end{tikzpicture}}
}

\begin{document}

\separator

\lipsum[1]

\end{document}


The lines have a width close to 1pt at this scale but not centered on the axis, hence the yshift gymnastics. You will have to adjust the values 1.15pt for the line thickness and .52pt for the y shift according to the value of \mylen and \textwidth to get things to match.

• Wouldn't the first coordinate of B rather be \textwidth - 1.15? I seem to get an overfull hbox otherwise. – Fatalize Oct 2 '17 at 13:35
• @Fatalize Thank you, I had overlooked the overfull box. It is better to shorten at both ends by half this amount to preserve symmetry. Code now modified. – Andrew Swann Oct 3 '17 at 6:05