Quero anexar uma folha de respostas a um exame. Porém, só consegui fazer isso manualmente, o que causa conflitos se eu fizer referência a coisas (por \cref
exemplo). Além disso, se for necessário reajustar os pontos da folha de respostas toda vez que eu os alterar nas questões. Existe uma maneira adequada de fazer isso?
\documentclass[addpoints, 12pt]{exam}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{subcaption}
\usepackage[nameinlink]{cleveref}
\pagestyle{headandfoot}
\firstpageheader{\large\bfseries Astronomy Exam\\ \bigskip
\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}}
\runningheader{\large\bfseries Last Name:\enspace\makebox[1.9in]{\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
answer sheets.}}}
\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
Answer sheet}}}
\end{center}
\bigskip
\begin{questions}
\question[60] Answer:
\vspace{\stretch{1}}
\question[40] Answer:
\vspace{\stretch{1}}
\end{questions}
\end{document}
Responder1
Olá, modifiquei a resposta deComo fazer com que o LaTeX se expanda na posição correta?para criar um novo ambiente para meu livreto de respostas.
Aqui está a solução usando seu MWE
\documentclass[addpoints, 12pt]{exam}
\pagestyle{headandfoot}
\firstpageheader{\large\bfseries Astronomy Exam\\ \bigskip
\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}}
\runningheader{\large\bfseries Last Name:\enspace\makebox[1.9in]{\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}}%
\immediate\write\verbatim@outSkr{\string\begin{ex@skripts}{\expandafter\thequestion. (\expandafter\totalpoints \ points) Answer:\string\par}}
\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
answer sheets.}}}
\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
Answer sheet}}}
\end{center}
\bigskip
\includeSkripts
\end{document}
Você pode renomear o script para algo mais óbvio, como caixa de resposta. Basicamente, ele apenas grava o conteúdo do ambiente em um arquivo e o exibe quando \includeSkripts
é chamado.