6

Could someone please share a working example of using the matching environment in a document class exam. I am new to using the exam document class and am unable to find a way to set up the matching style. I found exactly what I wanted in a document written in 2001, but cannot make it work in the new class. Here is what I have so far.

\documentclass[12pt]{exam}
% other information
\begin{document}

%exam header information

\begin{matching}[title={Match the following terms}]
    \pair{Field 1}{answer for 1}
    \pair{Field 2}{answer for 2}
    \pair{Field 3}{answer for 3}
\end{matching}

\end{document}

Thanks.

1

2 Answers 2

4

Here is the way I did it. I just used the tabular environment within the questions environment. The points can be counted with the question, but I do not have the solution print for this question. The macro \midmatch just puts in a line before each entry in the right column for the student to write the answer.

\newcommand{\midmatch}{\hspace{0.75in}\underline{\hspace{0.5in}     }}

Then, after the \begin{document}, within the questions environment:

\fullwidth{\section{Matching}}
\question[5]
Match the property of matter from the left column with the appropriate measurement device or technique on the right.
\begin{center}
\begin{tabular}{llll}
a.  &   Temperature &   \midmatch   &   Thermometer\\
&&&\\
b.  &   Pressure    &   \midmatch   &   Graduated Cylinder\\
&&&\\
c.  &   Length      &   \midmatch   &   Spectrometer\\
&&&\\
d.  &   Volume      &   \midmatch   &   Ruler\\
&&&\\
e.  &   Color       &   \midmatch   &   Manometer
\end{tabular}
\end{center}

Output

3

This answer may be helpful to you. Here's another that may give you some ideas but it does not use the exam class.

Here's my custom matching environment, based on this answer.

\documentclass[11pt]{exam}

%\printanswers

\usepackage{multicol}

%% Create a Matching question format
\newcommand*\Matching[1]{
\ifprintanswers
    \textbf{#1}
\else
    \rule{2.1in}{0.5pt}
\fi
}
\newlength\matchlena
\newlength\matchlenb
\settowidth\matchlena{\rule{2.1in}{0pt}}
\newcommand\MatchQuestion[2]{%
    \setlength\matchlenb{\linewidth}
    \addtolength\matchlenb{-\matchlena}
    \parbox[t]{\matchlena}{\Matching{#1}}\enspace\parbox[t]{\matchlenb}{#2}}


\begin{document}

\begin{questions}

\fullwidth{Match the \emph{most appropriate} term to each concept.  Not all terms are used. No term is used twice. (2 points each)}
\vspace{-1\baselineskip}
\fullwidth{%
\begin{multicols}{3}
Match 1 \\
Match 2 \\
Match 3 \\
Match 4 \\
Match 5 \\
Match 6 
\end{multicols}

}
\vspace{0.7\baselineskip}

\question\MatchQuestion{Match 3}{Which answer qoes with this question?}
\vspace{0.7\baselineskip}

\question\MatchQuestion{Match 5}{Which answer qoes with this question?}
\vspace{0.7\baselineskip}

\question\MatchQuestion{Match 2}{Which answer qoes with this question?}
\vspace{0.7\baselineskip}

\end{questions}

\end{document}

Blank lines are printed for the exams.

enter image description here

Answers are printed when \printanswers is uncommented.

enter image description here

You must log in to answer this question.

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