# hrulefill center text

So I am trying to center my text across the center of the \makebox.

Code:

\documentclass[12pt]{article}

\begin{document}
\makebox[2in]{\hrulefill\rlap{John Doe}\hrulefill}
\end{document}


Right now, the text is starting to appear at the center of the \makebox instead of being centered at \makebox's center. Is there a way to fix it?

\rlap produces a box of width 0 the left "anchor" of which is aligned with the current position. You need something that aligns the center of the current position. You can use either \makebox[0pt]{...} (or \makebox[0pt][c]{...}), or \clap{...} from the mathtools package for that.
\documentclass[12pt]{article}