I'd like to create an "answer blank" in a document. It should basically look like an underline with nothing above it. I found a question about it ( How does one TeX a blank? ), but that doesn't deal with the main problem I'm having, which is that I want the blank to wrap normally to the text width. The solutions using \hspace or \rule cause the line to extend into the margin.

I'm looking for something that wraps just like normal text and so won't extend into the margin. It should be an underlined blank that has a specified length, but that length might be wrapped across multiple lines in the output document.

2 Answers 2


With the following we define some building blocks 0.5 cm wide; with \blank{12} you'll get a 6cm wide line that can wrap, with a minimum of two blocks on either side; the minimum can be modified with the optional argument, with \blank[4]{12} the number of blocks will be 4 on either side.

\newcommand{\piece}{\hskip1sp\kern-1sp\hbox to .5cm{\hrulefill}}
\newcommand{\nbpiece}{\hbox to .5cm{\hrulefill}}

  \count@=\z@ \toks@={}%



A paragraph with \blank{12} and \blank{24} blanks.



If one wants to specify the length in centimeters instead of "number of blocks", it's sufficient to modify the definition of \blank as


The optional argument is still the minimum number of blocks on either side; with the default the minimum rule width is 1cm. A specification such as \blank{3} now means "build a rule 3cm wide" that can be split across lines".

If long rules are needed, for example to fill rows, it's convenient to change also the definition of \piece to allow a little backspacing in order to avoid overfull boxes

\newcommand{\piece}{\hskip0pt minus 3pt\hbox to .5cm{\hrulefill}}
  • Hmmm, thanks. This mostly does what I want, except that in some cases the box doesn't seem to shrink or grow when I change the number. Also, I tried changing it so the block size is 1cm, to make the length specification more natural (i.e., just {2} for 2cm), but then sometimes the blank extends out into the margin again. Is there any way to fix these issues?
    – BrenBarn
    Jul 5, 2011 at 3:43

One possibility: Use the \gap macro of the dashundergaps package, but remove the label after the "underlined blank".



\patchcmd{\gap}{\uline {#1} (\arabic {nth-gaps})}{\uline {#1}}{}{}


Here's a sentence with an \gap{xxxxxxxxxx xxxxxxxxxx xxxxxxxxxx xxxxxxxxxx xxxxxxxxxx xxxxxxxxxx xxxxxxxxxx} underlined blank that allows linebreaks.

  • This sort of works, but it produces unsightly extra space after the line.
    – BrenBarn
    Jul 4, 2011 at 3:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .