0

I am using the exam document class to create worksheets with fill-in-the-blank questions. By default, the \fillin command generates underlined empty space where students can write their answer. Is it possible to modify this behavior so that \fillin creates a box instead? Ideally I would be able to specify the height and the linewidth of the box. I would like to keep the ability to specify the correct solution to the \fillin command.

Minimal working example:

\documentclass{exam}
\begin{document}

\begin{questions}
\question How many grams are in one kilogram?

\vspace{1in}
1 kg = \fillin[1000] g.
\end{questions}

\end{document}

generates

enter image description here

but I would like to get something like

enter image description here

2 Answers 2

1

Without modifying the class:

\documentclass{exam}
\usepackage{xpatch}

\makeatletter
\xpatchcmd{\@fillin@relay}
  {\hbox to #1{\hrulefill}\fi}
  {\hbox{\framebox[#1]{\rule{0pt}{2ex}}}\fi}
  {}{}
\makeatother

\begin{document}

\begin{questions}
\question How many grams are in one kilogram?

1 kg = \fillin[1000] g.
\end{questions}

\end{document}

enter image description here

0

A workable solution to this problem is to make a copy of the exam.cls file, and replace the expression

\raise -\answerclearance \hbox to #1{\hrulefill}

(which appears twice in the section starting with \def\@fillin@relay around line 4482) by

\raisebox{\dimexpr 0.5em -0.5\height}{\framebox[#1]{{\rule{0pt}{0.5in}}}}

This will generate a 0.5 inch tall framebox where students can write their answer. The box is vertically centered with the surrounding text.

You must log in to answer this question.

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