> 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-tw/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,y,z\) 和 \(n\) 是
正整數，則 \(x^n + y^n = 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/13ae6f7c1634733c972a445f6c83ad3f496e9cab)

此 `questions` 環境的語法與 `itemize` 和 `enumerate` 環境非常相似。每一道題目都可以透過輸入指令 `\question` 來排版。

此範例中的其他指令並非專屬於 `exam` 類別，但可用來快速為你的考卷建立標題。

## 建立新題目

在前一節中，已展示如何建立題目的基本範例。題目還可以進一步自訂，本節將說明其方法。

### 間距

如果學生必須在提供的空間內作答，該空間可手動設定或平均分配。請看下面的範例：

```latex
\begin{questions}

\question 如果 \(x,y,z\) 和 \(n\) 是正整數，則 \(x^n + y^n = 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/0f2648dcabf34b58ed65be92dafe461368e0dd9d)

在這個範例中，指令 `\vspace{\stretch{1}}` 會在每個題目後平均分配可用空間。

命令 `\clearpage` 會插入分頁點，以便在新頁面繼續輸入題目。

如果你想手動指定每題的空間，請使用指令 `\vspace{}` 並在大括號之間寫入你需要的空間單位。例如， `\vspace{1in}` 會插入 1 英吋的垂直空間。請查看 [LaTeX 的長度](/latex/zh-tw/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/e938a872a396b2188d43785c986b5f4c148d1572)

這些環境 `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/9382320b6ec0a05901194b67ad17ffbda27da9f1)

在這個範例中，使用兩種不同的環境來列出選擇題的可能選項。

* 環境 `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/7d0534cbbaeca5675f23f0a5b96e167fdbf36fd9)

### 分數與半分數的計算

有時候在題目的某些部分加入半分數值會很方便。你可以這樣做，然後再印出整題的分數值。請看下面的範例：

```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/9723d8a073b52eba4ca52ffaeba3a17caf7404db)

命令 `\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}\)
\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/a17cea796b60b6575c9e83f03c26187067def235)

這些指令 `\bonusquestion` 和 `\bonuspart` 印出 `（bonus）` 在題目的分數值旁。

### 評分表

可以用特殊指令印出一個顯示每題分數的表格。

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

![ExamEx7.png](/files/03903b4ab2c20d69f642e44a38856dc338b017ed)

有三個指令可用來印出分數表：

**\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{問題 \thequestion：\totalpoints 分}

\chqword{問題}
\chpgword{頁面}
\chpword{分數}
\chbpword{加分}
\chsword{已得分數}
\chtword{總計}

...
```

![ExamEx8.png](/files/059dfc04693a3bc8cc10d20cf5d3f9815ca2e3ba)

文件其餘部分將與前面範例中顯示的完全相同。此處輸入的指令會變更 `exam` 類別的基本可運作範例開始。

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

將一般題目與小題中的 point 與 points 改為 punto 與 puntos。

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

在加分題與加分小題中，將 bonus point 與 bonus points 改為 punto extra 與 puntos extras。

**\totalformat{問題 \thequestion：\totalpoints 分}**

變更 \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
\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/6fb594fe829639c5d6d0f44de0a37165afbb48d3)

### 變更評分表中的預設名稱

這些指令取決於表格的格式與所顯示的資訊。每個指令中的 **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{總計}</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-tw/latex-ji-chu/01-learn-latex-in-30-minutes.md)
* [粗體、斜體與底線](/latex/zh-tw/latex-ji-chu/03-bold-italics-and-underlining.md)
* [清單](/latex/zh-tw/latex-ji-chu/04-lists.md)
* [數學表達式](/latex/zh-tw/shu-xue/01-mathematical-expressions.md)
* [下標與上標](/latex/zh-tw/shu-xue/02-subscripts-and-superscripts.md)
* [中括號與小括號](/latex/zh-tw/shu-xue/03-brackets-and-parentheses.md)
* [對齊方程式](/latex/zh-tw/shu-xue/06-aligning-equations-with-amsmath.md)
* [希臘字母與數學符號列表](/latex/zh-tw/shu-xue/11-list-of-greek-letters-and-math-symbols.md)
* [插入圖片](/latex/zh-tw/geng-duo-zhu-ti/27-inserting-images.md)
* [圖片與表格的定位](/latex/zh-tw/tu-biao-yu-biao-ge/02-positioning-images-and-tables.md)
* [字型大小、字族與樣式](/latex/zh-tw/zi-xing/01-font-sizes-families-and-styles.md)
* [字型字體](/latex/zh-tw/zi-xing/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-tw/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.
