I'd like to do something like this:
==================== Text ====================
Where '===' represents two horizontal lines separated by 2pt. In other words, I'd like to center some text between double horizontal lines. I have found a similar question here and attempted to adapt the following solution by egreg:
\newcommand{\textbetweenrules}[2][.4pt]{%
\par\vspace{\topsep}
\noindent\makebox[\textwidth]{%
\sbox0{#2}%
\dimen0=.5\dimexpr\ht0+#1\relax
\dimen2=-.5\dimexpr\ht0-#1\relax
\leaders\hrule height \dimen0 depth \dimen2\hfill
\quad #2\quad
\leaders\hrule height \dimen0 depth \dimen2\hfill
}\par\nopagebreak\vspace{\topsep}
}
And combine it with the solution given here for making double rules:
\hrule width \hsize \kern 1mm \hrule width \hsize
However, no matter what I try, the second \hrule doesn't seem to be recognized properly and I either get "height depth" printed on my document or nothing at all.
\documentclass{article}
\usepackage{lipsum}
\newcommand{\textbetweenrules}[2][.4pt]{%
\par\vspace{\topsep}
\noindent\makebox[\textwidth]{%
\sbox0{#2}%
\dimen0=.5\dimexpr\ht0+#1\relax
\dimen2=-.5\dimexpr\ht0-#1\relax
\leaders\hrule height \dimen0 depth \dimen2 \kern2pt \hrule height \dimen0 depth \dimen2\hfill
\quad #2\quad
\leaders\hrule height \dimen0 depth \dimen2 \kern2pt \hrule height \dimen0 depth \dimen2\hfill\hfill
}\par\nopagebreak\vspace{\topsep}
}
\begin{document}
\lipsum[2]
\textbetweenrules{Text}
\lipsum[3]
\end{document}



