# Shadowed Horizontal Line

I'm looking to insert a \hrulefill line with a shadow. Something that looks like this:

Help would be much appreciated.

## 2 Answers

Done in red to accentuate the effect. Obviously, the rule thicknesses, depths, etc. are set in the definition and can be altered.

\documentclass{article}
\newcommand\shadowfill{%
\leavevmode\leaders\hbox{\ooalign{%
\vrule height 1pt depth 0pt width 1pt\cr%
\textcolor{red}{\vrule height 0pt depth 1pt width 1pt}}%
}\hskip\fill\kern0pt%
}
\usepackage{xcolor}
\begin{document}
This is a test\shadowfill

or this\shadowfill

or maybe\shadowfill this

\shadowfill
\end{document}


ZOOM:

• How can I just do a horizontal line without having to add anything in front of it? Something like \hrulefill. If I just use \shadowfill, I end up with a "Leaders not followed by proper glue" error. – Chung Ren Khoo Oct 3 '18 at 15:22
• @ChungRenKhoo Sorry about that. I needed to add a \leavevmode at the beginning of the macro. See edit. – Steven B. Segletes Oct 3 '18 at 15:26
• I tried using it as a custom footer via \renewcommand{\footrule}{\shadowfill} but it doesn't show anything at all. Is there a fix around this? (This is for the fancyhdr package) – Chung Ren Khoo Oct 3 '18 at 15:49
• @ChungRenKhoo Perhaps \renewcommand{\footrule}{\makebox[\textwidth]{\shadowfill}}. I don't have a particular example to work with, but my guess is that the footer doesn't have a prescribed width to work with so you have to tell \shadowfill how long a width it should fill. – Steven B. Segletes Oct 3 '18 at 16:34

With blurred shadows.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shadows.blur,tikzmark}
\newcounter{fshadow}
\newcommand{\shadowfill}{\stepcounter{fshadow}
\tikzmark{XL-\thefshadow}\hrulefill\tikzmark{XR-\thefshadow}
\tikz[overlay,remember picture]{%
\path[blur shadow={shadow yshift=-0.4pt}] ([yshift=-0.2pt]pic cs:XL-\thefshadow) rectangle ([yshift=0.2pt]pic cs:XR-\thefshadow);}
}
\begin{document}

\shadowfill

abc\shadowfill def
\end{document}


• You always with TikZ!! Your rule seems more natural, congrats! – manooooh Oct 3 '18 at 3:15