1

I'm creating a form for people to print and fill out. Currently, I'm using

\usepackage[normalem]{ulem}
\begin{document}
    I, \uline{\hskip 3cm}, instated \uline{\hfill}
\end{document}

The only problem is that in a paragraph, there isn't enough vertical space to fill out the form. \spacing{1.3} is pretty good, but if there are no form elements, I don't want the extra space.

The following is close:

\usepackage[normalem]{ulem}
\begin{document}
    I, \raisebox{0pt}[2em]{\uline{\hskip 3cm}}, instated \raisebox{0pt}[2em]{\uline{\hfill}}
\end{document}

But the second line doesn't take any horizontal space (the \hrule seems to be ignored).

Is there a good way to fix my approach here, or should I use a different approach altogether?

2
  • 1
    The issue with your \raisebox variant is that \raisebox will first typeset its argument into a \hbox and in that the \hfill will not work.
    – Skillmon
    Commented Jan 30, 2020 at 19:07
  • @Skillmonlikestopanswers.xyz Thank you for mentioning topanswers.xyz, I'll take a look. Commented Jan 30, 2020 at 19:13

1 Answer 1

3

You don't need ulem at all to draw some lines, instead you can use some low-level TeX and use \leaders, which has the syntax:

\leaders<box><skip>

It inputs <box> as many times as necessary to fill out <skip>. In addition we put a \rule of zero thickness in front of the line. The height of that \rule will determine the space reserved for the hand writing. In the following I assume that a human can write into a 6mm high space without issues.

The macro \formline I created will take an optional argument specifying the width of the horizontal skip (and hence the line), if you don't provide any it'll use \hfill, else it'll use \hskip#1\relax.

I put some dummy content around your form lines to show that the vertical spacing gets stretched on the text lines containing the form lines:

\documentclass[]{article}

\newcommand\formline[1][\fill]
  {%
    \rule{0pt}{6mm}%
    \leaders\hbox{\rule[-1pt]{1pt}{.4pt}}\hskip #1\relax
    \null
  }

\usepackage{duckuments}

\begin{document}
\blindduck[1-]
I, \formline[3cm], instated \formline\\
\blindduck
I, \formline[3cm], instated \formline
\end{document}

enter image description here

2
  • Excellent answer. I went with \newcommand{\field}[2][6mm]{\rule{0pt}{#1}\leaders\hbox{\rule[-1pt]{1pt}{.6pt}}\hskip#2\relax\null} so I always specify the width of the field, and can optionally specify the height. I do see some irregularity in the underlines (since it's repeating a 1pt line over and over), but it doesn't show up when I print. Thanks so much! Commented Jan 31, 2020 at 5:47
  • 1
    @LimitedAtonement yes, those irregularities are usually errors during the anti-aliasing of the PDF viewers. I suggest when in doubt use xpdf to check on a big magnification, it does pretty precise rendering. And if still in doubt print a test page.
    – Skillmon
    Commented Jan 31, 2020 at 9:24

You must log in to answer this question.

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