Latest news 2021-09-06: new blog post "Legacy Documents and TeX Live Docker Images".

# 11. ⁑Forms

There aren't very many entries on CTAN that deal with forms. At the time of writing there are four entries listed in the form-fillin topic and only one of them, formular [115], is in both MiKTeX and TeX Live. If you are interested in writing proposals, there is also a proposal topic but again there aren't many entries in it. Some of the exam/assignment classes or packages (see §9 Assignments and Examinations) that have multiple choice or fill-in-the-blank options could also be used to create forms.

As with leaflets and flyers, forms don't really conform to standard typesetting styles. Small forms, such as the one for contact details in Example 51, can be created using tabular-like environments with \hrulefill or \dotfill for ruled or dotted line areas. There are font packages available that provide tick and cross symbols [65], such as pifont [84] and wasysym [42]. The decoration topic includes packages, such as framed [3] or mdframed [20], that can place frames around regions of text.

The code for the query form from Example 51 is reproduced in the document below. This just uses the standard article class instead of the leaflet class used in that example:

\documentclass{article}

\usepackage{wasysym}

\begin{document}
\section{Query Form}

If you'd like to know more about the exciting collaboration between
the Secret Lab of Experimental Stuff and the Department of Stripy
Confectioners please fill in your details below and post this slip to:

\bigskip

\begin{tabular}{@{}l}
Miss Ingperson\\
Secret Lab of Experimental Stuff\\
University of Somewhere\\
Some City\\
AB3 4YZ
\end{tabular}

\bigskip

\Square\␣I agree to having my memory wiped.

\Square\␣Yes, I'd really like to feed the ducks.

\bigskip

\begin{tabular}{@{}lp{4cm}}
Name: & \dotfill \\
& \dotfill \\
& \dotfill \\
& \dotfill \\
Postcode: & \dotfill\\
Country: & \dotfill\\
Telephone: & \dotfill\\
Mobile: & \dotfill\\
Email: & \dotfill
\end{tabular}

\end{document}


Both \dotfill and \hrulefill are leaders [46] and fill the available horizontal space. In the above example, I used the column identifier p{4cm} to create a column of width 4 cm, which gives \dotfill 4 cm of horizontal space to fill. If I'd just used the l left alignment column identifier then no dotted line would have appeared.

Example

Some text\hrulefill Some more text.

Some text\dotfill Some more text.

\hrulefill Some text\dotfill Some more text.\hrulefill



produces:

You can place a leader inside a fixed-width box. For example:

The \makebox[3em]{\hrulefill} sat on the \makebox[3em]{\hrulefill}. 

which produces:

A cut line can be produced with a combination of leaders and a pair of scissors symbol from a package such as pifont. For example:

\par\noindent
\makebox[2em]{\dotfill}\ding{33}\dotfill\par


which produces:

Note that this doesn't extend the cut line into the margins. To achieve that you need to use some negative length and a horizontal box with width given by \paperwidth. For example:

\par\noindent
\hspace*{-\dimexpr 1in+\hoffset+\oddsidemargin}%
\rlap{%
\makebox[\paperwidth][l]{%
\makebox[4em]{\dotfill}\ding{33}\dotfill
}}\par


For a two-sided document you will need to check if the current page is odd or even. For example:

\par\noindent
\ifodd\value{page}\relax
\hspace*{-\dimexpr 1in+\hoffset+\oddsidemargin}%
\else
\hspace*{-\dimexpr 1in+\hoffset+\evensidemargin}%
\fi
\rlap{%
\makebox[\paperwidth][l]{%
\makebox[4em]{\dotfill}\ding{33}\dotfill
}}\par


[Finding if you're on an odd or an even page] Be careful using this method of testing for an odd or even page, as it may not always work due to TeX's asynchronous output routine. If you are using one of the KOMA-Script classes, you can use KOMA-Script's \ifthispageodd command to determine if the current page is odd or even in a more robust manner.

You may find it easier to define a command that produces this with an optional argument to determine the distance between the start of the line and the scissor symbol. For example:

\newcommand{\cutline}[1][4em]{%
\par\noindent
\ifodd\value{page}\relax
\hspace*{-\dimexpr 1in+\hoffset+\oddsidemargin}%
\else
\hspace*{-\dimexpr 1in+\hoffset+\evensidemargin}%
\fi
\rlap{%
\makebox[\paperwidth][l]{%
\makebox[#1]{\dotfill}\ding{33}\dotfill
}}\par
}


Now you can just use this command, for example:

\cutline[6em] 

Remember that if you want a hard copy this requires borderless printing otherwise a slim margin may still appear (as occurs in the paperback version of this book).

If you are using the flowfram package, you also need to take into account any additional offset caused by a frame that doesn't have its left edge flush against the left edge of the typeblock. In this case the definition of \cutline needs to be adjusted as follows:

\newlength\frameoffset

\newcommand{\cutline}[1][4em]{%
\par\noindent
\ifodd\value{page}\relax
\computeleftedgeodd{\frameoffset}%
\getflowbounds{\value{thisframe}}%
\else
\computeleftedgeeven{\frameoffset}%
\getflowevenbounds{\value{thisframe}}%
\fi
\hspace*{\frameoffset}%
\rlap{%
\makebox[\paperwidth][l]{%
\makebox[#1]{\dotfill}\ding{33}\dotfill
}}\par
}


Exercise 29. Query Form

Reproduce the earlier query form from Example 51 as a single-paged document (for example, using article or scrartcl) with no page numbering and a cut line between the submission address and the actual form.

This book is also available as A4 PDF or 12.8cm x 9.6cm PDF or paperback (ISBN 978-1-909440-07-4).

© 2015 Dickimaw Books. "Dickimaw", "Dickimaw Books" and the Dickimaw parrot logo are trademarks. The Dickimaw parrot was painted by Magdalene Pritchett.