# How to append answer sheet to exam? (Exam document class)

I want to append an answer sheet to an exam. However, I only managed to do so manually, which causes conflicts if I reference things (with \cref for instance). Also, if have to re-adjust the points in the answer sheet every time I change them in the questions. Is there a proper way of doing this?

\documentclass[addpoints, 12pt]{exam}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{subcaption}

\large\bfseries Last Name:\enspace\makebox[1.9in]{\hrulefill}}
{}
{\large\bfseries Univ ID: \makebox[2in]{\hrulefill} \\  \bigskip
\large\bfseries First Name:\enspace\makebox[2in]{\hrulefill}}
{}
{\large\bfseries First Name:\enspace\makebox[2in]{\hrulefill}}
\firstpagefooter{}{}{}
\runningfooter{}{\thepage}{}

\begin{document}

\begin{center}
\fbox{\fbox{\parbox{5.5in}{\centering
Answer the questions in the spaces provided on the
\end{center}

\begin{questions}

\question[60] Explain Principle A

\question[40] Explain Principle B

\end{questions}

\newpage

\begin{center}
\fbox{\fbox{\parbox{5.5in}{\centering
\end{center}
\bigskip

\begin{questions}

\vspace{\stretch{1}}

\vspace{\stretch{1}}

\end{questions}

\end{document}

• And the option to answer the questions below the question is not ok? For that you could use: \begin{solutionordottedlines}[5cm] \end{solutionordottedlines} There are a lot of variaties of this. Feb 13, 2016 at 12:16
• The problem is that some student have attempted to change their answers when they got it back. So I usually scan exams before returning to them. With answers all in the back, I don't have to scan everything. Feb 13, 2016 at 20:04
• I see, no LaTeX solution for that from my part. A student solution: empty desk, and give it back at the end off the class? :-( Feb 13, 2016 at 20:15

Hi I modified the answer from How to get LaTeX to expand at the correct position? to create a new environment for my answer booklet.

Here's the solution using your MWE

\documentclass[addpoints, 12pt]{exam}

\large\bfseries Last Name:\enspace\makebox[1.9in]{\hrulefill}}
{}
{\large\bfseries Univ ID: \makebox[2in]{\hrulefill} \\  \bigskip
\large\bfseries First Name:\enspace\makebox[2in]{\hrulefill}}
{}
{\large\bfseries First Name:\enspace\makebox[2in]{\hrulefill}}
\firstpagefooter{}{}{}
\runningfooter{}{\thepage}{}

\usepackage{verbatim}

\newenvironment{ex@skripts}[1]{#1}{}

\makeatletter
\newwrite\verbatim@outSkr % Define file.
\immediate\openout\verbatim@outSkr=\jobname.skr  % Open file for writing.

\def\skript{
\@bsphack
\let\do\@makeother\dospecials
\catcode\^^M\active
\def\verbatim@processline{%
\immediate\write\verbatim@outSkr{\the\verbatim@line}}%
\verbatim@start}

\def\endskript{%
\immediate\write\verbatim@outSkr{\string\end{ex@skripts}}
\@esphack}

\newcommand*{\includeSkripts}{%
\immediate\closeout\verbatim@outSkr    % Close file.
\InputIfFileExists{\jobname.skr}{}{}
\newwrite\verbatim@outSkr % Datei wird definiert
\immediate\openout\verbatim@outSkr=\jobname.skr  % Open file for writing.
}
\makeatother

\begin{document}

\begin{center}
\fbox{\fbox{\parbox{5.5in}{\centering
Answer the questions in the spaces provided on the
\end{center}

\begin{questions}

\question[60] Explain Principle A

\begin{skript}
\vspace{\stretch{1}}
\end{skript}

\question[40] Explain Principle B

\begin{skript}
\vspace{\stretch{1}}
\end{skript}

\end{questions}

\newpage

\begin{center}
\fbox{\fbox{\parbox{5.5in}{\centering

You can rename skript to something more obvious like answerbox. Basically it just writes the contents of the environment to a file and outputs it when \includeSkripts` is called.