3

I would like to make a name and address fill-in-the-blank in a neat rectangle with a lined space where the information should be filled in. At first I came up with this:

\begin{tabular}{ll}
\multicolumn{2}{l}{NAME\underline{\hspace{15em}}\\
\multicolumn{2}{l}{ADDRESS\underline{\hspace{15em}}} \\
\multicolumn{2}{l}{CITY\underline{\hspace{15em}}} \\
STATE\underline{\hspace{3em}} & ZIP\underline{\hspace{8em}}
\end{tabular}

But this yields a ragged right edge and tinkering with the \hspace{} parameters is a non-starter. I tried this:

\begin{tabular}{ll}
\multicolumn{2}{l}{NAME\underline{\hspace{15em}}\\
\multicolumn{2}{l}{ADDRESS\underline{\h fill}} \\
\multicolumn{2}{l}{CITY\underline{\hfill}} \\
STATE\underline{\hspace{3em}} & ZIP\underline{\hfill}
\end{tabular}

But I get no underlines at all with the \hfills. I don't want to simply make this a tabular with \hlines because that will result in underlined field names or gaps between the field names and the underlining.

migrated from stackoverflow.com Jul 22 '13 at 13:02

This question came from our site for professional and enthusiast programmers.

3

It is far easier to leave the guess-work to TeX. In the example below I've fixed the tabular to a single paragraph column of width 20em. Rules are inserted using leaders (via \hrulefill):

enter image description here

\documentclass{article}
\begin{document}
\noindent
\begin{tabular}{@{}p{20em}@{}}
  NAME~\hrulefill \\
  ADDRESS~\hrulefill \\
  CITY~\hrulefill \\
  STATE~\hrulefill\quad ZIP~\hrulefill\hrulefill
\end{tabular}
\end{document}​

The rule associated with ZIP is twice that of STATE, as suggested by the double \hrulefill. The total width of the table is 20em, since padding on either end has been removed with @{}.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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