In LaTeX, how would I make a long underscore?
For example,
Name _______ Signature _______
In LaTeX, how would I make a long underscore?
For example,
Name _______ Signature _______
You can just \underline a \hspace:
\documentclass{article}
\begin{document}
Name \underline{\hspace{3cm}}
Signature \underline{\hspace{3cm}}
\end{document}

\hspace isn't necessarily "better" than just using a rule, but if you are placing the rule after a word, the \underline will place it lower than the baseline, which looks better in most cases. so it saves a bit of decision making.
– barbara beeton
Aug 03 '11 at 12:54
#em instead of #cm in order to make the length of the underscore depend on the font’s width.
– Júda Ronén
Dec 30 '14 at 17:38
You can use \rule:
\rule[<raise height>]{<width>}{<height>}
For example \rule{2in}{.5pt} will give you the sort of thing you want.
The optional argument can be used to raise (positive value) or lower (negative value) the rule. Sometimes lowering it slightly looks better.
As I learned from the exam class's documentation, you can do this:
\makebox[0.5\textwidth]{Name:\enspace\hrulefill}
which allows you to control how much space the entire construction takes up, rather than just the underlined part.
A code such as
\newcommand\blank[1]{\rule[-.2ex]{#1}{.4pt}}
in your preamble allows you to say
\blank{2cm}
instead of your complicated construction.
If you want a line (or rule) at the baseline of a specific length (and width), you can just use \rule{<len>}{<width>}. You can also adjust the vertical displacement (or depth) by adding an optional argument: \rule[<depth>]{<len>}{<width>}.
Here's a mock-up using an example:

\documentclass{article}
\newcommand{\uline}[1]{\rule[0pt]{#1}{0.4pt}}% Fill this blank
\begin{document}
Assume $A \subset B$.
We want to show $A \subset (A \cap B)$ and \uline{2cm}.
The first fact is true since: $A \subset B \Rightarrow$
if $x \in A$ then \uline{2cm} $\Rightarrow$
if $x \in A$ then $x \in A and B$.
The second fact is true by \uline{2cm}.
Conversly, assume \uline{2cm}.
By the first property again, $B \supset$ \uline{2cm},
so we have \uline{4cm}.
\end{document}
I've defined \uline to take a single argument, fixing the others passed to \rule (width is 0.4pt and depth is 0pt). You can modify this as required, depending on the preference.
\rule anymore, but it still seems like it did. Could somebody mark the update?
– Blaisorblade
Mar 26 '13 at 12:11
In ConTeXt you can use the command \thinrules. The optional parameter n outputs a particular amount of lines. Example:
\starttext Some text \thinrules[n=1] \blank Some text \thinrules[n=2] \stoptext
The result:

You can also use the soul package. This has the added benefit that the underline can be of a different color, and also should be able to work across paragraph boundaries (except that there appears to be a bug, so had to add the \mbox below for now.
\documentclass{article}
\usepackage{xcolor}%
\usepackage{soul}%
\newcommand{\UnderlineText}[2][red]{\setulcolor{#1}\ul{#2}}%
\begin{document}
Signature \UnderlineText[blue]{\mbox{\hspace{5cm}}}
\end{document}
soul package. Instead, you can just use the \color command from the xcolor package: \color{red}{\underline{\hspace{3cm}}}
– Jake
Aug 03 '11 at 05:31
\UnderlineText to obtain an underline of a different coloring than the text, but since in this case there is no text that is not really an issue. Hopefully, once the related problem is solved, this solution will be of some use as the \ul will handle line boundaries.
– Peter Grill
Aug 03 '11 at 05:35