# Horizontal line without vertical gap

I'm trying to create a underlined heading like this, without space between John Smith and the underline

I tried this command, but it adds a vertical gap between the name and the underline

\noindent\rule[0ex]{\linewidth}{0.5pt}

• Hove you tried overlapping them, using \rlap and possibly \raisebox? – John Kormylo Feb 2 '16 at 4:16
• The [0ex] in your command is telling TeX you want the rule raised by 0ex. Perhaps something like [2ex] would suit you better. – jon Feb 2 '16 at 4:32
• Hell World, or Hello World? :-) – Mico Feb 2 '16 at 7:29

Try this

\documentclass{article}

\begin{document}

\noindent
\makebox[0pt][l]{\Large\bfseries John Smith}%%
\rule[-0.5ex]{\columnwidth}{0.4pt}

Hell world, this is my cover letter.

\end{document}


There are commands like \rlap and \\lap. But, I think \makebox is kind of fun. You can set the width of the box and the alignment to be left, right, or center.

\documentclass{article}

\begin{document}

\noindent
\rule[-0.5ex]{\columnwidth}{0.4pt}%%
\hspace*{-\dimexpr\columnwidth/2}%%
\makebox[0pt]{\Large\bfseries John Smith}%%
\hspace*{\dimexpr\columnwidth/2}%%

Hell world, this is my cover letter.

\end{document}


Following this general idea, you can create nice commands like the following

\documentclass{article}

\rule[-0.5ex]{#1}{0.4pt}%%
\hspace*{-\dimexpr#1/2}%%
\hspace*{\dimexpr#1/2}}

\begin{document}


By uncommending the line with \aeShowAnswerstrue results in
• Or: John Smith\par \rule[2ex]{\linewidth}{0.5pt} (with \noindents as appropriate -- hard to say in OP's question how \parindent is working). --- Love the "Hell world" though: how all cover letters should start! – jon Feb 2 '16 at 5:19