> For the complete documentation index, see [llms.txt](https://ayakaleaf-pro.ayaka.space/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ayakaleaf-pro.ayaka.space/latex/zh-cn/te-ding-ling-yu/09-typesetting-exams-in-latex.md).

# 在 LaTeX 中排版试卷

## 引言

LaTeX 类 `exam.cls` 使创建试卷和排版题目变得非常简单。它在所有纸张尺寸中都设置了 1 英寸页边距，并提供用于记录和计算分数的特殊命令。要使用 `exam` 类，你必须加入这一行

```latex
\documentclass{exam}
```

在你的 `.tex` 文件开头。这将启用该宏包与考试相关的命令，并将页面格式设置为留出批改边距。

## 基本示例

让我们从一个基本可运行的 `exam` 类示例开始。

```latex
\documentclass{exam}

\begin{document}

\begin{center}
\fbox{\fbox{\parbox{5.5in}{\centering
请在提供的空白处作答。如果答题空间不够
，请在页面背面继续作答。}}}
\end{center}

\vspace{5mm}
\makebox[0.75\textwidth]{姓名与班级：\enspace\hrulefill}

\vspace{5mm}
\makebox[0.75\textwidth]{教师姓名：\enspace\hrulefill}

\begin{questions}
\question 若 \(x^n + y^n = z^n\) 对于 \(x,y,z\) 和 \(n\) 是
正整数？请解释。

\question 证明函数
\(\zeta(z)\) 的所有非平凡零点的实部都是 \(\frac{1}{2}\)

\question 计算 \[\int_{0}^{\infty} \frac{\sin(x)}{x}\]
\end{questions}
\end{document}
```

[在 Overleaf 中打开此示例](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Basic+exam+class+example\&snip=%5Cdocumentclass%7Bexam%7D%0A%0A%5Cbegin%7Bdocument%7D%0A%0A%5Cbegin%7Bcenter%7D%0A%5Cfbox%7B%5Cfbox%7B%5Cparbox%7B5.5in%7D%7B%5Ccentering%0AAnswer+the+questions+in+the+spaces+provided.+If+you+run+out+of+room%0Afor+an+answer%2C+continue+on+the+back+of+the+page.%7D%7D%7D%0A%5Cend%7Bcenter%7D%0A%0A%5Cvspace%7B5mm%7D%0A%5Cmakebox%5B0.75%5Ctextwidth%5D%7BName+and+section%3A%5Censpace%5Chrulefill%7D%0A%0A%5Cvspace%7B5mm%7D%0A%5Cmakebox%5B0.75%5Ctextwidth%5D%7BInstructor%E2%80%99s+name%3A%5Censpace%5Chrulefill%7D%0A%0A%5Cbegin%7Bquestions%7D%0A%5Cquestion+Is+it+true+that+%5C%28x%5En+%2B+y%5En+%3D+z%5En%5C%29+if+%5C%28x%2Cy%2Cz%5C%29+and+%5C%28n%5C%29+are%0Apositive+integers%3F.+Explain.%0A%0A%5Cquestion+Prove+that+the+real+part+of+all+non-trivial+zeros+of+the+function%0A%5C%28%5Czeta%28z%29%5C%29+is+%5C%28%5Cfrac%7B1%7D%7B2%7D%5C%29%0A%0A%5Cquestion+Compute+%5C%5B%5Cint_%7B0%7D%5E%7B%5Cinfty%7D+%5Cfrac%7B%5Csin%28x%29%7D%7Bx%7D%5C%5D%0A%5Cend%7Bquestions%7D%0A%5Cend%7Bdocument%7D)

![ExamEx1OLV2b.png](/files/799b10590d21a288ff27676a1343af225acb04ac)

的语法 `questions` 环境与 `itemize` 和 `enumerate` 环境非常相似。每个题目通过在其前面输入命令 `\question` 即可。

本示例中的其他命令并非该 `exam` 类所特有，但可用于快速为你的试卷创建页眉。

## 创建新题目

在上一节中，介绍了一个展示如何创建题目的基本示例。题目还可以进一步自定义，本节将说明如何操作。

### 间距

如果要求学生在提供的空间中作答，该空间可以手动设置或平均分配。见下例：

```latex
\begin{questions}

\question 若 \(x^n + y^n = z^n\) 对于 \(x,y,z\) 和 \(n\) 是正整数？请解释。
\vspace{\stretch{1}}

\question 证明函数 \(\zeta(z)\) 的所有非平凡零点的实部都是 \(\frac{1}{2}\)
\vspace{\stretch{1}}

\question 计算 \[\int_{0}^{\infty} \frac{\sin(x)}{x}\]
\vspace{\stretch{1}}

\end{questions}
\clearpage
```

[在 Overleaf 中打开此示例](https://www.overleaf.com/docs?engine=\&snip_name=Providing+space+for+exam+questions\&snip=%5Cdocumentclass%7Bexam%7D%0A%0A%5Cbegin%7Bdocument%7D%0A%0A%5Cbegin%7Bcenter%7D%0A%5Cfbox%7B%5Cfbox%7B%5Cparbox%7B5.5in%7D%7B%5Ccentering%0AAnswer+the+questions+in+the+spaces+provided.+If+you+run+out+of+room%0Afor+an+answer%2C+continue+on+the+back+of+the+page.%7D%7D%7D%0A%5Cend%7Bcenter%7D%0A%0A%5Cvspace%7B5mm%7D%0A%5Cmakebox%5B0.75%5Ctextwidth%5D%7BName+and+section%3A%5Censpace%5Chrulefill%7D%0A%0A%5Cvspace%7B5mm%7D%0A%5Cmakebox%5B0.75%5Ctextwidth%5D%7BInstructor%E2%80%99s+name%3A%5Censpace%5Chrulefill%7D%0A%5Cbegin%7Bquestions%7D%0A%0A%5Cquestion+Is+it+true+that+%5C%28x%5En+%2B+y%5En+%3D+z%5En%5C%29+if+%5C%28x%2Cy%2Cz%5C%29+and+%5C%28n%5C%29+are+positive+integers%3F.+Explain.%0A%5Cvspace%7B%5Cstretch%7B1%7D%7D%0A%0A%5Cquestion+Prove+that+the+real+part+of+all+non-trivial+zeros+of+the+function+%5C%28%5Czeta%28z%29%5C%29+is+%5C%28%5Cfrac%7B1%7D%7B2%7D%5C%29%0A%5Cvspace%7B%5Cstretch%7B1%7D%7D%0A%0A%5Cquestion+Compute+%5C%5B%5Cint_%7B0%7D%5E%7B%5Cinfty%7D+%5Cfrac%7B%5Csin%28x%29%7D%7Bx%7D%5C%5D%0A%5Cvspace%7B%5Cstretch%7B1%7D%7D%0A%0A%5Cend%7Bquestions%7D%0A%5Cclearpage%0A%5Cend%7Bdocument%7D)

下图展示了这段代码的输出——当你打开链接时，LaTeX 文档导言区会自动添加：

![ExamEx2OLV2.png](/files/ff945bfc242890fda0a93ac5a4bdfdc314ae1f88)

在此示例中，命令 `\vspace{\stretch{1}}` 会在每道题后平均分配可用空间。

命令 `\clearpage` 插入一个分页点，以便在新页面继续输入题目。

如果你想手动为每道题分配空间，请使用命令 `\vspace{}` 并在花括号中写入你需要的空间单位。例如， `\vspace{1in}` 插入 1 英寸的垂直空间。请查看关于 [LaTeX 中长度的文档](/latex/zh-cn/ge-shi-hua/01-lengths-in-latex.md) 以获取可用单位列表。

### 子题部分

如果你的题目有若干部分，聚焦于某些子主题，你可以使用以下环境： `parts`, `subparts`, `subsubparts` 以及相应的命令 `\part`, `\subpart` 和 `\subsubpart`。请看下一个示例：

```latex
\begin{questions}
\question 已知方程 \(x^n + y^n = z^n\) 对于 \(x,y,z\) 和 \(n\) 正的
整数。
\begin{parts}
\part 当 \(n\) 取何值时，上一题中的陈述成立？
\vspace{\stretch{1}}

\part 当 \(n=2\) 时，有一个带特殊名称的定理。这个名称是什么？
\vspace{\stretch{1}}

\part 哪位著名数学家曾为这个定理给出过优雅的证明，但是
页边没有足够空间把它写下来？
\vspace{\stretch{1}}

\begin{subparts}
\subpart 实际上是谁证明了这个定理？
\vspace{\stretch{1}}
\subpart 实际上花了多长时间才解决这个问题？
\vspace{\stretch{1}}
\end{subparts}

\end{parts}

\question 证明函数
\(\zeta(z)\) 的所有非平凡零点的实部都是 \(\frac{1}{2}\)
...

\end{questions}
```

[在 Overleaf 中打开此示例](https://www.overleaf.com/docs?engine=\&snip_name=Multipart+exam+questions\&snip=%5Cdocumentclass%7Bexam%7D%0A%5Cbegin%7Bdocument%7D%0A%0A%5Cbegin%7Bcenter%7D%0A%5Cfbox%7B%5Cfbox%7B%5Cparbox%7B5.5in%7D%7B%5Ccentering%0AAnswer+the+questions+in+the+spaces+provided.+If+you+run+out+of+room%0Afor+an+answer%2C+continue+on+the+back+of+the+page.%7D%7D%7D%0A%5Cend%7Bcenter%7D%0A%0A%5Cvspace%7B5mm%7D%0A%5Cmakebox%5B0.75%5Ctextwidth%5D%7BName+and+section%3A%5Censpace%5Chrulefill%7D%0A%0A%5Cvspace%7B5mm%7D%0A%5Cmakebox%5B0.75%5Ctextwidth%5D%7BInstructor%E2%80%99s+name%3A%5Censpace%5Chrulefill%7D%0A%5Cbegin%7Bquestions%7D%0A%5Cquestion+Given+the+equation+%5C%28x%5En+%2B+y%5En+%3D+z%5En%5C%29+for+%5C%28x%2Cy%2Cz%5C%29+and+%5C%28n%5C%29+positive%0Aintegers.+%0A%5Cbegin%7Bparts%7D%0A%5Cpart+For+what+values+of+%5C%28n%5C%29+is+the+statement+in+the+previous+question+true%3F%0A%5Cvspace%7B%5Cstretch%7B1%7D%7D%0A%0A%5Cpart+For+%5C%28n%3D2%5C%29+there%27s+a+theorem+with+a+special+name.+What%27s+that+name%3F%0A%5Cvspace%7B%5Cstretch%7B1%7D%7D%0A%0A%5Cpart+What+famous+mathematician+had+an+elegant+proof+for+this+theorem+but%0Athere+was+not+enough+space+in+the+margin+to+write+it+down%3F%0A%5Cvspace%7B%5Cstretch%7B1%7D%7D%0A%0A%5Cbegin%7Bsubparts%7D%0A%5Csubpart+Who+actually+proved+the+theorem%3F%0A%5Cvspace%7B%5Cstretch%7B1%7D%7D%0A%5Csubpart+How+long+did+actually+take+to+solve+this+problem%3F%0A%5Cvspace%7B%5Cstretch%7B1%7D%7D%0A%5Cend%7Bsubparts%7D%0A%0A%5Cend%7Bparts%7D%0A%0A%5Cquestion+Prove+that+the+real+part+of+all+non-trivial+zeros+of+the+function+%0A%5C%28%5Czeta%28z%29%5C%29+is+%5C%28%5Cfrac%7B1%7D%7B2%7D%5C%29%0A...%0A%0A%5Cend%7Bquestions%7D%0A%5Cend%7Bdocument%7D)

下图展示了这段代码的输出——当你打开链接时，LaTeX 文档导言区会自动添加：

![ExamEx3OLV2.png](/files/c38b888529d7d9bbe3f16d93cf6e36aa11bf4d31)

这些环境 `parts` 和 `subparts` 提供类似题目的嵌套列表。就像在题目中一样，你也可以手动设置垂直间距。

## 选择题

有四种环境可用于创建选择题。

```latex
\begin{questions}
\question 下面这些著名物理学家中，谁发明了时间？

\begin{oneparchoices}
 \choice Stephen Hawking
 \choice Albert Einstein
 \choice Emmy Noether
 \choice 这毫无意义
\end{oneparchoices}

\question 下面这些著名物理学家中，谁发表过一篇关于布朗运动的论文？

\begin{checkboxes}
 \choice Stephen Hawking
 \choice Albert Einstein
 \choice Emmy Noether
 \choice 我不知道
\end{checkboxes}
\end{questions}
```

[在 Overleaf 中打开此示例](https://www.overleaf.com/docs?engine=\&snip_name=Multiple+choice+exam+example\&snip=%5Cdocumentclass%7Bexam%7D%0A%5Cbegin%7Bdocument%7D%0A%5Cbegin%7Bquestions%7D%0A%5Cquestion+Which+of+these+famous+physicists+invented+time%3F%0A%0A%5Cbegin%7Boneparchoices%7D%0A+%5Cchoice+Stephen+Hawking+%0A+%5Cchoice+Albert+Einstein%0A+%5Cchoice+Emmy+Noether%0A+%5Cchoice+This+makes+no+sense%0A%5Cend%7Boneparchoices%7D%0A++++%0A%5Cquestion+Which+of+these+famous+physicists+published+a+paper+on+Brownian+Motion%3F%0A%0A%5Cbegin%7Bcheckboxes%7D%0A+%5Cchoice+Stephen+Hawking+%0A+%5Cchoice+Albert+Einstein%0A+%5Cchoice+Emmy+Noether%0A+%5Cchoice+I+don%27t+know%0A%5Cend%7Bcheckboxes%7D%0A%5Cend%7Bquestions%7D%0A%5Cend%7Bdocument%7D)

下图展示了这段代码的输出——当你打开链接时，LaTeX 文档导言区会自动添加：

![ExamMulti.png](/files/17ead9071e5d49d4d1ead9b2e6bab6fb710d9d10)

在此示例中，使用了两种不同的环境来列出选择题的可选项。

* 环境 `oneparchoices` 用大写字母标记选项并水平排列。如果你希望选项以列表形式排版，则环境 `choices` 是合适的选择。
* 环境 `checkboxes` 在每个选项前打印复选框。如果你需要将选项水平排列，请使用环境 `oneparcheckboxes` 代替。

## 评分

该 `exam` 类的另一个重要特性是，它提供了使试卷评分更轻松的命令。

### 每道题的分值

你可以为每个 `\question` 或 `\part` 添加一个参数，以打印正确回答该题所能获得的分值。题目或部分后方方括号中的附加参数表示分配给它的分值。你可以更改分值的显示样式和位置，详见 [参考指南](#reference-guide) 以获取更多命令。

```latex
\begin{questions}
\question 已知方程 \(x^n + y^n = z^n\) 对于 \(x,y,z\) 和 \(n\) 正的
整数。
\begin{parts}
\part[10] 当 \(n\) 取何值时，上一题中的陈述成立？
\vspace{\stretch{1}}

\part[10] 当 \(n=2\) 时，有一个带特殊名称的定理。这个名称是什么？
\vspace{\stretch{1}}

\part[10] 哪位著名数学家曾为这个定理给出过优雅的证明，但是
页边没有足够空间把它写下来？
\vspace{\stretch{1}}

\end{parts}

\question[20] 计算 \[\int_{0}^{\infty} \frac{\sin(x)}{x}\]

\vspace{\stretch{1}}
\end{questions}
```

[在 Overleaf 中打开此示例](https://www.overleaf.com/docs?engine=\&snip_name=Adding+points+to+exam+questions\&snip=%5Cdocumentclass%7Bexam%7D%0A%5Cbegin%7Bdocument%7D%0A%5Cbegin%7Bquestions%7D%0A%5Cquestion+Given+the+equation+%5C%28x%5En+%2B+y%5En+%3D+z%5En%5C%29+for+%5C%28x%2Cy%2Cz%5C%29+and+%5C%28n%5C%29+positive%0Aintegers.+%0A%5Cbegin%7Bparts%7D%0A%5Cpart%5B10%5D+For+what+values+of+%5C%28n%5C%29+is+the+statement+in+the+previous+question+true%3F%0A%5Cvspace%7B%5Cstretch%7B1%7D%7D%0A%0A%5Cpart%5B10%5D+For+%5C%28n%3D2%5C%29+there%27s+a+theorem+with+a+special+name.+What%27s+that+name%3F%0A%5Cvspace%7B%5Cstretch%7B1%7D%7D%0A%0A%5Cpart%5B10%5D+What+famous+mathematician+had+an+elegant+proof+for+this+theorem+but+there+was%0Anot+enough+space+in+the+margin+to+write+it+down%3F%0A%5Cvspace%7B%5Cstretch%7B1%7D%7D%0A%0A%5Cend%7Bparts%7D%0A%0A%5Cquestion%5B20%5D+Compute+%5C%5B%5Cint_%7B0%7D%5E%7B%5Cinfty%7D+%5Cfrac%7B%5Csin%28x%29%7D%7Bx%7D%5C%5D%0A%0A%5Cvspace%7B%5Cstretch%7B1%7D%7D%0A%5Cend%7Bquestions%7D%0A%5Cend%7Bdocument%7D)

下图展示了这段代码的输出——当你打开链接时，LaTeX 文档导言区会自动添加：

![ExamEx4OLV2b.png](/files/d049968de1cc1eb5f2aa78b8ef93c3a4336f1c3b)

### 分值和半分值计数

有时在题目的各部分中加入半分值会更方便。你可以这样做，然后打印整道题的总分。见下例：

```latex
\documentclass[addpoints]{exam}
\begin{document}
\begin{questions}
\question 已知方程 \(x^n + y^n = z^n\) 对于 \(x,y,z\) 和 \(n\) 正的
整数。
\begin{parts}
\part[5] 当 \(n\) 取何值时，上一题中的陈述成立？
\vspace{\stretch{1}}

\part[2 \half] 当 \(n=2\) 时，有一个带特殊名称的定理。这个名称是什么？
\vspace{\stretch{1}}

\part[2 \half] 哪位著名数学家曾为这个定理给出过优雅的证明，但是
页边没有足够空间把它写下来？
\vspace{\stretch{1}}

\end{parts}

\droptotalpoints

\question[20] 计算 \[\int_{0}^{\infty} \frac{\sin(x)}{x}\]
\end{questions}
\end{document}
```

[在 Overleaf 中打开此示例](https://www.overleaf.com/docs?engine=\&snip_name=exam+package+counting+points+and+half+points\&snip=%5Cdocumentclass%5Baddpoints%5D%7Bexam%7D%0A%5Cbegin%7Bdocument%7D%0A%5Cbegin%7Bquestions%7D%0A%5Cquestion+Given+the+equation+%5C%28x%5En+%2B+y%5En+%3D+z%5En%5C%29+for+%5C%28x%2Cy%2Cz%5C%29+and+%5C%28n%5C%29+positive%0Aintegers.+%0A%5Cbegin%7Bparts%7D%0A%5Cpart%5B5%5D+For+what+values+of+%5C%28n%5C%29+is+the+statement+in+the+previous+question+true%3F%0A%5Cvspace%7B%5Cstretch%7B1%7D%7D%0A%0A%5Cpart%5B2+%5Chalf%5D+For+%5C%28n%3D2%5C%29+there%27s+a+theorem+with+a+special+name.+What%27s+that+name%3F%0A%5Cvspace%7B%5Cstretch%7B1%7D%7D%0A%0A%5Cpart%5B2+%5Chalf%5D+What+famous+mathematician+had+an+elegant+proof+for+this+theorem+but+there+was%0Anot+enough+space+in+the+margin+to+write+it+down%3F%0A%5Cvspace%7B%5Cstretch%7B1%7D%7D%0A%0A%5Cend%7Bparts%7D%0A%0A%5Cdroptotalpoints%0A%0A%5Cquestion%5B20%5D+Compute+%5C%5B%5Cint_%7B0%7D%5E%7B%5Cinfty%7D+%5Cfrac%7B%5Csin%28x%29%7D%7Bx%7D%5C%5D%0A%5Cend%7Bquestions%7D%0A%5Cend%7Bdocument%7D)

下图展示了这段代码的输出——当你打开链接时，LaTeX 文档导言区会自动添加：

![ExamCountPointsOLV2.png](/files/9f0c8e254b8492ce1deebcb3a96817932f13ba9a)

命令 `\half` 为题目添加半分值。命令 `\droptotalpoints` 会打印上一题的总分。要使该命令生效，你必须在文档类声明中添加选项 `[addpoints]` 到文档类声明中。

### 附加分

可以添加附加题，这些额外分数稍后会显示在 [评分表中](#grading-table)。添加附加题和附加部分实际上与创建常规题目和部分一样简单。

```latex
\begin{questions}

\question 已知方程 \(x^n + y^n = z^n\) 对于 \(x,y,z\) 和 \(n\) 正的
整数。
\begin{parts}
\part[5] 当 \(n\) 取何值时，上一题中的陈述成立？
\vspace{\stretch{1}}

\part[2 \half] 当 \(n=2\) 时，有一个带特殊名称的定理。这个名称是什么？
\vspace{\stretch{1}}

\bonuspart[2 \half] 哪位著名数学家曾为这个定理给出过优雅的证明，但是
页边没有足够空间把它写下来？
\vspace{\stretch{1}}

\end{parts}

\droptotalpoints

\question[20] 计算 \[\int_{0}^{\infty} \frac{\sin(x)}{x}\]

\vspace{\stretch{1}}

\bonusquestion[30] 证明函数 \(\zeta(z)\) 的所有非平凡零点的实部都是 \(\frac{1}{2}\)
\(\zeta(z)\) 的所有非平凡零点的实部都是 \(\frac{1}{2}\)
\vspace{\stretch{1}}

\end{questions}
```

[在 Overleaf 中打开此示例](https://www.overleaf.com/docs?engine=\&snip_name=exam+package+and+bonus+points\&snip=%5Cdocumentclass%5Baddpoints%5D%7Bexam%7D%0A%5Cbegin%7Bdocument%7D%0A%5Cbegin%7Bquestions%7D%0A%0A%5Cquestion+Given+the+equation+%5C%28x%5En+%2B+y%5En+%3D+z%5En%5C%29+for+%5C%28x%2Cy%2Cz%5C%29+and+%5C%28n%5C%29+positive%0Aintegers.+%0A%5Cbegin%7Bparts%7D%0A%5Cpart%5B5%5D+For+what+values+of+%5C%28n%5C%29+is+the+statement+in+the+previous+question+true%3F%0A%5Cvspace%7B%5Cstretch%7B1%7D%7D%0A%0A%5Cpart%5B2+%5Chalf%5D+For+%5C%28n%3D2%5C%29+there%27s+a+theorem+with+a+special+name.+What%27s+that+name%3F%0A%5Cvspace%7B%5Cstretch%7B1%7D%7D%0A%0A%5Cbonuspart%5B2+%5Chalf%5D+What+famous+mathematician+had+an+elegant+proof+for+this+theorem+but+there+was%0Anot+enough+space+in+the+margin+to+write+it+down%3F%0A%5Cvspace%7B%5Cstretch%7B1%7D%7D%0A%0A%5Cend%7Bparts%7D%0A%0A%5Cdroptotalpoints%0A%0A%5Cquestion%5B20%5D+Compute+%5C%5B%5Cint_%7B0%7D%5E%7B%5Cinfty%7D+%5Cfrac%7B%5Csin%28x%29%7D%7Bx%7D%5C%5D%0A%0A%5Cvspace%7B%5Cstretch%7B1%7D%7D%0A%0A%5Cbonusquestion%5B30%5D+Prove+that+the+real+part+of+all+non-trivial+zeros+of+the+function+%0A%5C%28%5Czeta%28z%29%5C%29+is+%5C%28%5Cfrac%7B1%7D%7B2%7D%5C%29%0A%5Cvspace%7B%5Cstretch%7B1%7D%7D%0A%0A%5Cend%7Bquestions%7D%0A%5Cend%7Bdocument%7D)

下图展示了这段代码的输出——当你打开链接时，LaTeX 文档导言区会自动添加：

![ExamEx6OLV2file.png](/files/6de4817443d31139f790847a4169bdff6cd4120a)

这些命令 `\bonusquestion` 和 `\bonuspart` 打印 `（附加）` 放在题目分值旁边。

### 评分表

可以使用一个特殊命令打印显示每道题分值的表格。

```latex
\begin{center}
\combinedgradetable[h][questions]
\end{center}
```

![ExamEx7.png](/files/5af05e821dc0ba53a02d1348cfb80bba8fbf4af1)

有三个用于打印评分表的命令：

**\gradetable**

打印与常规题目对应的成绩表。如果有附加题，则不包含在内。

**\bonusgradetable**

只打印与附加题对应的成绩表

**\combinedgradetable**

打印同时包含常规题目和附加题的表格。

这些命令需要两个额外参数，每个参数都放在方括号中。

* 第一个可以是 `[h]` 用于横向表格，或者 `[v]` 用于纵向表格。
* 第二个参数设置表格的索引方式： `[questions]` 按题目编号索引分值，且 `[pages]` 按页码列出分值。

## Overleaf 考试项目示例

上述示例已组合成一个基础项目模板，可作为你工作的起点。你可以通过点击/选择以下链接创建新项目： [打开一个 Overleaf `exam` 项目示例](https://www.overleaf.com/project/new/template/20093?id=68314645\&templateName=Example+project+using+the+exam+class\&latexEngine=pdflatex\&texImage=texlive-full%3A2020.1\&mainFile=) .

### 其他语言

在该 `exam` 类中不支持英语以外的语言。不过，将默认词汇翻译成你的本地语言很容易。上面的项目包含一段被注释掉的代码片段，演示如何将某些文档元素翻译成西班牙语。

```latex
\usepackage[spanish]{babel}

\pointpoints{punto}{puntos}
\bonuspointpoints{punto extra}{puntos extra}

\totalformat{Pregunta \thequestion: \totalpoints puntos}

\chqword{Pregunta}
\chpgword{Página}
\chpword{Puntos}
\chbpword{Puntos extra}
\chsword{Puntos obtenidos}
\chtword{Total}

...
```

![ExamEx8.png](/files/8288930d0a79c14bd755b3753d75bbcb0d057207)

文档的其余部分将与前面的示例完全相同。此处输入的命令会更改文档中的默认词汇 `exam` 类示例开始。

**\pointpoints{punto}{puntos}**

将常规题目和部分中的 point 和 points 改为 punto 和 puntos。

**\bonuspointpoints{punto extra}{puntos extra}**

在附加题和附加部分中，将 bonus point 和 bonus points 改写为 punto extra 和 puntos extras。

**\totalformat{Pregunta \thequestion: \totalpoints puntos}**

更改 \droptotalpoints 打印的文本。在示例中，它打印 Pregunta 1: 7 1/2 puntos。

**\chqword{Pregunta}**

将评分表中的 Question 改为 Pregunta。其余命令会更改该表中的其他词语，\chpgword 对应 Page，\chpword 对应 Points，\chbpword 对应 Bonus points，\chsword 对应 Score，\chtword 对应 Total。这些命令可能会根据你正在创建的表格类型而变化，请参阅参考指南以了解其他表格所需的命令。

## 参考指南

### 题目分值标记的位置与格式设置

这些命令可以写在导言区，以更改整个文档的格式；也可以写在题目之前，以将格式从该题开始一直应用到下一个格式命令或文档结尾。

* `\poinstinmargin` （或者 `\pointsinleftmargin`）将使分值打印在左边距中。
* `\pointsinrightmargin` 将使分值打印在右边距中。
* `\nopointsinmargin` （或者 `\nopointsinrightmargin`）将恢复为默认情况。
* `\bracketedpoints` 将在分值外使用方括号而不是圆括号。
* `\boxedpoints` 在分值周围绘制一个方框。

下面是一个使用 `\pointsinmargin` 和 `\pointsinrightmargin`:

```latex
这里我们将使用 \verb|\pointsinmargin|
\begin{questions}
\pointsinmargin
\question 已知方程 \(x^n + y^n = z^n\) 对于 \(x,y,z\) 和 \(n\) 正的
整数。
\begin{parts}
\part[5] 当 \(n\) 取何值时，上一题中的陈述成立？
\vspace{40pt}

\part[2 \half] 当 \(n=2\) 时，有一个带特殊名称的定理。这个名称是什么？
\vspace{40pt}

\part[2 \half] 哪位著名数学家曾为这个定理给出过优雅的证明，但是
页边没有足够空间把它写下来？

\vspace{40pt}
\end{parts}

现在我们将使用 \verb|\pointsinrightmargin|

\pointsinrightmargin
\question 已知方程 \(x^n + y^n = z^n\) 对于 \(x,y,z\) 和 \(n\) 正的
整数。
\begin{parts}
\part[5] 当 \(n\) 取何值时，上一题中的陈述成立？
\vspace{40pt}

\part[2 \half] 当 \(n=2\) 时，有一个带特殊名称的定理。这个名称是什么？
\vspace{40pt}

\part[2 \half] 哪位著名数学家曾为这个定理给出过优雅的证明，但是
页边没有足够空间把它写下来？
整数。
\end{parts}
\end{questions}
```

[在 Overleaf 中打开此示例](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=exam+class+with+point+in+margins\&snip=%5Cdocumentclass%5Baddpoints%5D%7Bexam%7D%0A%5Cusepackage%5Ba4paper%2C+total%3D%7B6in%2C+8in%7D%5D%7Bgeometry%7D%0A%5Cbegin%7Bdocument%7D%0AHere+we%27ll+use+%5Cverb%7C%5Cpointsinmargin%7C%0A%5Cbegin%7Bquestions%7D%0A%5Cpointsinmargin%0A%5Cquestion+Given+the+equation+%5C%28x%5En+%2B+y%5En+%3D+z%5En%5C%29+for+%5C%28x%2Cy%2Cz%5C%29+and+%5C%28n%5C%29+positive%0Aintegers.+%0A%5Cbegin%7Bparts%7D%0A%5Cpart%5B5%5D+For+what+values+of+%5C%28n%5C%29+is+the+statement+in+the+previous+question+true%3F%0A%5Cvspace%7B40pt%7D%0A%0A%5Cpart%5B2+%5Chalf%5D+For+%5C%28n%3D2%5C%29+there%27s+a+theorem+with+a+special+name.+What%27s+that+name%3F%0A%5Cvspace%7B40pt%7D%0A%0A%5Cpart%5B2+%5Chalf%5D+What+famous+mathematician+had+an+elegant+proof+for+this+theorem+but+there+was%0Anot+enough+space+in+the+margin+to+write+it+down%3F%0A%0A%5Cvspace%7B40pt%7D%0A%5Cend%7Bparts%7D%0A%0ANow+we%27ll+use+%5Cverb%7C%5Cpointsinrightmargin%7C%0A%0A%5Cpointsinrightmargin%0A%5Cquestion+Given+the+equation+%5C%28x%5En+%2B+y%5En+%3D+z%5En%5C%29+for+%5C%28x%2Cy%2Cz%5C%29+and+%5C%28n%5C%29+positive%0Aintegers.+%0A%5Cbegin%7Bparts%7D%0A%5Cpart%5B5%5D+For+what+values+of+%5C%28n%5C%29+is+the+statement+in+the+previous+question+true%3F%0A%5Cvspace%7B40pt%7D%0A%0A%5Cpart%5B2+%5Chalf%5D+For+%5C%28n%3D2%5C%29+there%27s+a+theorem+with+a+special+name.+What%27s+that+name%3F%0A%5Cvspace%7B40pt%7D%0A%0A%5Cpart%5B2+%5Chalf%5D+What+famous+mathematician+had+an+elegant+proof+for+this+theorem+but+there+was%0Anot+enough+space+in+the+margin+to+write+it+down%3F%0Aintegers.+%0A%5Cend%7Bparts%7D%0A%5Cend%7Bquestions%7D%0A%5Cend%7Bdocument%7D)

下图显示了上述代码的输出：

![Examclassmargins.png](/files/f837c37d86f0fd5dbb7e0a685cd61dbf2cdc6581)

### 更改评分表中的默认名称

这些命令取决于表格的格式以及表中显示的信息。 **h** 和 **v** 在每个命令中表示横向或纵向。如果命令前面带有 **b** 表示它会更改附加题表中的格式；如果命令前面带有 **c** 表示它作用于组合表。例如，要在纵向附加题表中将 “Score” 改为 “Points Awarded”，你应使用 `\bvsword{Points Awarded}`.

下方显示了一个使用默认值的表格。

|          | **横向**                                                                                                                                                                                                               | **纵向**                                                                                                                                                                                                           |
| -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **成绩表**  | <p><code>\hqword{Question:}</code><br><code>\hpgword{Page:}</code><br><code>\hpword{Points:}</code><br><code>\hsword{Score:}</code><br><code>\htword{Total}</code></p>                                               | <p><code>\vqword{Question}</code><br><code>\vpgword{Page}</code><br><code>\vpword{Points}</code><br><code>\vsword{Score}</code><br><code>\vtword{Total:}</code></p>                                              |
| **附加分表** | <p><code>\bhqword{Question:}</code><br><code>\bhpgword{Page:}</code><br><code>\bhpword{Bonus Points:}</code><br><code>\bhsword{Score:}</code><br><code>\bhtword{Total}</code></p>                                    | <p><code>\bvqword{Question}</code><br><code>\bvpgword{Page}</code><br><code>\bvpword{Bonus Points}</code><br><code>\bvsword{Score}</code><br><code>\bvtword{Total:}</code></p>                                   |
| **组合表**  | <p><code>\chqword{Question:}</code><br><code>\chpgword{Page:}</code><br><code>\chpword{Points:}</code><br><code>\chbpword{Bonus Points:}</code><br><code>\chsword{Score:}</code><br><code>\chtword{Total}</code></p> | <p><code>\cvqword{Question}</code><br><code>\cvpgword{Page}</code><br><code>\cvpword{Points}</code><br><code>\cvbpword{Bonus Points}</code><br><code>\cvsword{Score}</code><br><code>\cvtword{Total:}</code></p> |

## 进一步阅读

更多信息请参见：

* [在 LaTeX 中创建文档](/latex/zh-cn/latex-ji-chu/01-learn-latex-in-30-minutes.md)
* [粗体、斜体和下划线](/latex/zh-cn/latex-ji-chu/03-bold-italics-and-underlining.md)
* [列表](/latex/zh-cn/latex-ji-chu/04-lists.md)
* [数学表达式](/latex/zh-cn/shu-xue/01-mathematical-expressions.md)
* [下标和上标](/latex/zh-cn/shu-xue/02-subscripts-and-superscripts.md)
* [方括号和圆括号](/latex/zh-cn/shu-xue/03-brackets-and-parentheses.md)
* [对齐公式](/latex/zh-cn/shu-xue/06-aligning-equations-with-amsmath.md)
* [希腊字母和数学符号列表](/latex/zh-cn/shu-xue/11-list-of-greek-letters-and-math-symbols.md)
* [插入图片](/latex/zh-cn/geng-duo-zhu-ti/27-inserting-images.md)
* [图片和表格的定位](/latex/zh-cn/tu-xing-he-biao-ge/02-positioning-images-and-tables.md)
* [字体大小、字体族和样式](/latex/zh-cn/zi-ti/01-font-sizes-families-and-styles.md)
* [字体类型](/latex/zh-cn/zi-ti/02-font-typefaces.md)
* [该 **exam** class 文档](https://mirror.ox.ac.uk/sites/ctan.org/macros/latex/contrib/exam/examdoc.pdf).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://ayakaleaf-pro.ayaka.space/latex/zh-cn/te-ding-ling-yu/09-typesetting-exams-in-latex.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
