Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

In LaTeX, how would I make a long underscore?

For example,

Name _______  Signature _______
share|improve this question
5  
Those should be lines (rules) and not underscores. –  Caramdir Aug 3 '11 at 4:22
1  
possible duplicate of How can i add a "field" for handwritten text? –  Caramdir Aug 3 '11 at 4:22
3  
@Caramdir Oddly though, the simple solutions like mine and Jake's don't appear there. –  Alan Munn Aug 3 '11 at 4:34
5  
@Neil I think the way you've posed the question is nice and simple and captures what many people have a need for; the other question is really quite a bit more complicated, so I think we shouldn't close this one. (I'd also wait a bit before accepting either answer.) –  Alan Munn Aug 3 '11 at 4:39
1  
@RyanReich: Oh geez :( I really didn't mean to be discourteous. To be fair, I had already upvoted your answer and the other one, but looking back, I thought the underline solution produced a rule that was below the text and that seems better to me now. I thought since all three top answers had 10k+ rep, you wouldn't even notice! If you think reaccepting yours is more courteous, I'd be happy to. –  Neil G Jun 12 '13 at 22:49

7 Answers 7

up vote 51 down vote accepted

You can just \underline a \hspace:

\documentclass{article}

\begin{document}
Name \underline{\hspace{3cm}}
Signature \underline{\hspace{3cm}}

\end{document}

underlined spaces

share|improve this answer
2  
Is this better than just using a rule? If so, how? –  Seamus Aug 3 '11 at 10:39
2  
@Seamus -- using \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 3 '11 at 12:54
    
This is the easiest solution –  Neil G Aug 3 '11 at 22:46
1  
@Seamus: It also uses the standard line thickness, so you don't run the risk of making the line slightly too thick or thin. –  Jake Aug 3 '11 at 23:13

You can use \rule:

\rule[<raise height>]{<width>}{<height>}}

For example \rule{2in}{.5pt} will give you the kind 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.

share|improve this answer
    
This is a good solution if you want fine control over the dimensions. –  Neil G Aug 3 '11 at 18:54

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.

share|improve this answer

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.

share|improve this answer

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:

enter image description here

\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.

share|improve this answer
    
I'm confused - the answer does not modify \rule anymore, but it still seems like it did. Could somebody mark the update? –  Blaisorblade Mar 26 '13 at 12:11
1  
@Blaisorblade: Yes, I'll flag the comments as obsolete and request a moderator to remove them. You can see the original entries as part of the post history/revisions. –  Werner Mar 26 '13 at 14:21

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:

result

share|improve this answer

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}
share|improve this answer
3  
If all you want is a coloured line, you don't need the soul package. Instead, you can just use the \color command from the xcolor package: \color{red}{\underline{\hspace{3cm}}} –  Jake Aug 3 '11 at 5:31
    
@Jake: Good point. I have been using the \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 3 '11 at 5:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.