A Simple Form Class
First the code for the class file simple-form.cls:
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{simple-form}[2014/10/11]
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}
\ProcessOptions
\LoadClass[a4paper,12pt]{article}
\RequirePackage{etoolbox}
\RequirePackage{wasysym}
\newcommand*{\form@fillin}[2]{%
\makebox[#1][l]{\rlap{#2}\hrulefill}%
}
\newcommand*{\form@checked}{\XBox}
\newcommand*{\form@unchecked}{\Square}
\newcommand*{\form@layout@checkbox}[2]{#1 #2}
\newcommand*{\form@layout@fillin}[3]{#3: \form@fillin{#1}{#2}}
\newcommand*\@name{}
\newcommand*{\name}[1]{%
\renewcommand*{\@name}{#1}%
}
\newcommand*{\gender@male}{\form@unchecked}
\newcommand*{\gender@female}{\form@unchecked}
\newcommand*{\gender}[1]{%
\ifcsdef{gender@#1}%
{\csdef{gender@#1}{\form@checked}}
{\ClassError{simple-form}
{Unknown gender `#1'}%
{Options: `male', `female'}}
}
\newcommand{\makeform}{%
\form@layout@fillin{8em}{\@name}{Name}\qquad
\form@layout@fillin{12em}{\@date}{Date}%
\par
\bigskip
\par
\form@layout@checkbox{\gender@male}{Male}\qquad
\form@layout@checkbox\gender@female{Female}%
}
\endinput
Now the sample document:
\documentclass{simple-form}
\name{Mabel Canary}
\gender{female}
\begin{document}
\makeform
\end{document}
Download simple-form.cls and simple-form-example.tex or simple-form-example.pdf.
