我想在考试中附加答题纸。但是,我只能手动完成,如果我引用某些内容(例如\cref
),这会导致冲突。此外,每次我在问题中更改要点时,我都必须重新调整答题纸中的要点。有没有正确的方法可以做到这一点?
\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}
答案1
嗨,我修改了答案如何让 LaTeX 在正确的位置展开?为我的答题册创造一个新的环境。
这是使用 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}
您可以将 skript 重命名为更明显的名称,例如 answerbox。基本上,它只是将环境的内容写入文件并在\includeSkripts
调用时将其输出。