TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way to make an underlined text field in a fillable form?

I am using the hyperref package to make a fillable form but I would also like to give the option of printing out the form and filling it by hand. For the later, a line is helpful to serve as guide for the pen.


\TextField[name=firstname,width=5cm,charsize=11pt]{First Name}

gives an empty box and I cannot find an easy way to underline this box.

share|improve this question
Welcome to TeX.SX. – Claudio Fiandrino Mar 9 '13 at 13:01

The printing of the field is controlled by \MakeTextField whose default definition is equivalent to

\newcommand{MakeTextField}[2]{\vbox to #2{\hbox to #1{\hfill}\vfill}}

Replacing the inside \hfill with an \hrulefill produces a horizontal line, but because of the placing of the \vfill these will be at the top of the box. Moving the placement of \vfill gives a line at the bottom via

\renewcommand{\MakeTextField}[2]{{\vbox to #2{\vfill\hbox to #1{\hrulefill}}}}

You will probably want to adjust the colour to black (rather than the gray I get as default):

Sample output



\renewcommand{\MakeTextField}[2]{{\vbox to #2{\vfill\hbox to #1{\hrulefill}}}}

  \TextField[name=firstname,width=5cm,charsize=11pt,color=black]{First Name}
share|improve this answer
Thanks, that solved it. – latexform Mar 10 '13 at 7:40
Strangely, this doesn't seem to do anything in pdflatex, though it does give lines in xelatex. You wouldn't know why that is, would you? – leftaroundabout Apr 1 '15 at 13:43
The above sample is pdflatex, so I guess it is an April fool. – Andrew Swann Apr 8 '15 at 12:23

Your Answer


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.