I'm wondering how to make something like this:
---------------------------------- Text -------------------------------------
In words: the text is centered. There is some space between the lines and the text. The lines are aligned vertically with the center of the text and extend to the margin on either side, so that the total length is \textwidth
. Here is the idea:
\documentclass{article}
\begin{document}
\centering{\rule[0.5ex]{4.5cm}{2pt} \hspace{0.6cm} Text \hspace{0.6cm} \rule[0.5ex]{4.5cm}{2pt}}
\end{document}
Edit: The length of the lines should change, not of the space.
Best Answer
Extensible rules and customizable height:
Edit: This is the output produced:
Edit 2: Sorry, I had completely overlooked the requirement concerning the vertical alignment of the rules; as a sort of over-compensation, the following code tries to thoroughly address this issue:
I think the starred form of the
\genhrulefill
command should be the preferred one.Output: