> For the complete documentation index, see [llms.txt](https://overleaf-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://overleaf-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}
如果 \(x,y,z\) 和 \(n\) 是正整数，那么 \(x^n + y^n = z^n\) 这句话成立吗？
正整数？请解释。

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

计算 \[\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}

如果 \(x,y,z\) 和 \(n\) 是正整数，那么 \(x^n + y^n = z^n\) 这句话成立吗？请解释。
\vspace{\stretch{1}}

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

计算 \[\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}
如果给定方程 \(x^n + y^n = z^n\)，其中 \(x,y,z\) 和 \(n\) 为正
整数。
\begin{parts}
对于 \(n\) 的哪些取值，上一个问题中的命题成立？
\vspace{\stretch{1}}

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

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

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

\end{parts}

证明函数
\(\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}
以下这些著名物理学家中，谁发明了时间？

\begin{oneparchoices}
 \choice 斯蒂芬·霍金
 \choice 阿尔伯特·爱因斯坦
 \choice 埃米·诺特
 \choice 这毫无道理
\end{oneparchoices}

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

\begin{checkboxes}
 \choice 斯蒂芬·霍金
 \choice 阿尔伯特·爱因斯坦
 \choice 埃米·诺特
 \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}
如果给定方程 \(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}
如果给定方程 \(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}

如果给定方程 \(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}\)
\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{题目：}
\chpgword{页码：}
\chpword{分值：}
\chbpword{附加分：}
\chsword{得分}
\chtword{总计}

...
```

![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{题目：}**

将评分表中的单词 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
如果给定方程 \(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
如果给定方程 \(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** 每个命令中的 h 和 v 分别表示横向或纵向。如果命令前带有 **b** ，则表示它更改的是附加题表格中的格式；如果命令前带有 **c** ，则表示它适用于组合表格。例如，要将纵向附加题表格中的“Score”改为“Points Awarded”，你应使用 `\bvsword{已得分}`.

下方显示的是带有默认值的表格。

|          | **横向**                                                                                                                                                                                    | **纵向**                                                                                                                                                                                |
| -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **分数表**  | <p><code>\hqword{题目：}</code><br><code>\hpgword{页码：}</code><br><code>\hpword{分值：}</code><br><code>\hsword{得分：}</code><br><code>\htword{总计}</code></p>                                      | <p><code>\vqword{题目}</code><br><code>\vpgword{页码}</code><br><code>\vpword{分值}</code><br><code>\vsword{得分}</code><br><code>\vtword{总计：}</code></p>                                     |
| **附加分表** | <p><code>\bhqword{题目：}</code><br><code>\bhpgword{页码：}</code><br><code>\bhpword{附加分：}</code><br><code>\bhsword{得分：}</code><br><code>\bhtword{总计}</code></p>                                | <p><code>\bvqword{题目}</code><br><code>\bvpgword{页码}</code><br><code>\bvpword{附加分}</code><br><code>\bvsword{得分}</code><br><code>\bvtword{总计：}</code></p>                               |
| **组合表**  | <p><code>\chqword{题目：}</code><br><code>\chpgword{页码：}</code><br><code>\chpword{分值：}</code><br><code>\chbpword{附加分：}</code><br><code>\chsword{得分：}</code><br><code>\chtword{总计}</code></p> | <p><code>\cvqword{题目}</code><br><code>\cvpgword{页码}</code><br><code>\cvpword{分值}</code><br><code>\cvbpword{附加分}</code><br><code>\cvsword{得分}</code><br><code>\cvtword{总计：}</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-biao-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** 类文档](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://overleaf-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.
