Is there a simple way to have text that looks like this?
--- text ---
where the --- fills a certain width? I've tried
\centerline{\rule{2cm}{.4pt}text\rule{2cm}{.4pt}}
but here if "text" is "text_1" in one case and "text_123" in another, then the total width of the text plus rule varies in each case.


\leaders\hrulewill use a single rule, rather than repeating small boxes containing a rule. You can use\leaders\hrule height \dimexpr.5ex+.2pt\relax depth \dimexpr -.5ex+.2pt\relax \hfillto have it centered at mid x-height. – egreg Oct 16 '12 at 08:03