我的班上有很多学生,我想为每一位学生提供一份指定考试。但是,使用以下方法,成绩表、问题总数和总分数都是错误的,请参阅所附屏幕截图。
我正在使用“考试”类。
\begin{filecontents*}{students.lst}
Sam Student
John Doe
Bat Man
\end{filecontents*}
\documentclass[addpoints,12pt]{exam}
\usepackage{textmerg,titling,enumitem,kantlipsum}
\newlist{examqns}{enumerate}{1}
\setlist[examqns]{label=Question \arabic*, font=\bfseries, wide, ref=\arabic*}
\begin{document}
\title{Exam --- Fall 2022}
\date{Date of Examination}
\Fields{\studentname}
\Merge{students.lst}{%
\clearpage% use \cleardoublepage if printing double-sided
\author{\bf{\studentname}}
\maketitle
%---
The exam has \numpages\ page and \numquestions\ questions that result in \numpoints\ points. \\
%\noindent
\begin{center}
\addpoints
\gradetable[h][questions]
\end{center}
\rule[1ex]{\textwidth}{1pt}
%content---
\begin{questions}
\question[10]
Why is there air?
\question
What if there were no air?
\begin{parts}
\part[5]
Describe the effect on the balloon industry.
\part[5]
Describe the effect on the aircraft industry.
\end{parts}
\question[10] If the universe were to end, how would you know?
\begin{parts}
\part Define the universe. Give three examples.
\part Compute x2 dx.
\end{parts}
\end{questions}
%---
}
\end{document}
答案1
它比我的评论稍微复杂一些,但要点就在那里。棘手的部分是找到名字应该放在哪里。
\documentclass[]{article}
\usepackage{textmerg}
\usepackage{pdfpages}
\usepackage{tikzpagenodes}
\pagestyle{empty}
\begin{document}
\Fields{\studentname}
\Merge{students.lst}{%
\begin{tikzpicture}[remember picture, overlay]
\node at (current page.center) {\includegraphics[page=1]{test6}};% original PDF
\path (current page text area.north) ++(0,-1.7cm) node{\textbf{\huge\studentname}};
\end{tikzpicture}%
\newpage
%\includepdf[pages={2-}]{test6}
}
\end{document}
此版本将名称放在每一个页。
\documentclass[]{article}
\usepackage{textmerg}
\usepackage{pdfpages}
\AddToHook{shipout/foreground}{\put ({\dimexpr 1in+\oddsidemargin},-6.5cm)
{\makebox[\textwidth]{\textbf{\huge\studentname}}}}
\pagestyle{empty}
\begin{document}
\Fields{\studentname}
\Merge{students.lst}{%
\includepdf{test6}
}
\end{document}