2007年12月13日 星期四

LaTeX package - exam - part 1

第二部份

1. 簡介
簡單的說,exam 這種文件格式就是設計用來出考卷的。


3. documentclass 指令
要使用 exam 這種格式,你得在 \documentclass 做設定。舉例來說,如果你要使用 12pt 大小的字型,那你的 documentclass 指令應該是像這樣子
\documentclass[12pt]{exam}
如果你還要用上 amsmath 這個 package,那你的指令就應該是
\documentclass[12pt]{exam}
\usepackage{amsmath}
如果你在考卷上有附上解答,而你想把他在 LaTeX 裡印出來,那你還得加上 answer 這個選項,像是這樣子
\documentclass[answer]{exam}
或者是像這樣子
\documentclass[12pt,answer]{exam}
不過這是可選擇的,你也可以利用 \printanswers 這個指令來達到同樣的效果。


3. 學生的姓名
你可以利用下面的方式來印出卷首的部份,寫下注意事項以及要學生寫下姓名
\begin{center}
\fbox{\fbox{\parbox{5.5in}{\centering
Answer the questions in the spaces provided on the
question sheets. If you run out of room for an answer,
continue on the back of the page.}}}
\end{center}
\vspace{0.1in}
\hbox to \textwidth{Name and section:\enspace\hrulefill}
\vspace{0.2in}
\hbox to \textwidth{Instructor’s name:\enspace\hrulefill}


5. 題目 - questions
要開始寫考卷,你得使用 questions 模式,而每題題目前面都要加上 \question 這個指令,這樣子一來每題題目前面都會自動加上題號。舉例來說
\begin{questions}
\question
Why is there air?

\question
How much wood would a woodchuck chuck if a woodchuck could chuck wood?

\question
Compute $\displaystyle\int_0^1 x^2 \, dx$.
\end{questions}


5.1. 題目中的子題 - parts、subparts、subsubparts
如果你要在題目裡面還要有子題,那你就要在 questions 模式裡再進入 parts 模式,例如
\begin{questions}
\question
Why is there air?

\question
What if there were no air?

\begin{parts}
\part
Describe the effect on the balloon industry.

\part
Describe the effect on the aircraft industry.
\end{parts}

\question
\begin{parts}
\part
Define the universe. Give three examples.

\part
If the universe were to end, how would you know?

\end{parts}

\end{questions}

上面的例子說明了幾件事
* 子題必須放在 parts 模式下
* 如果題目一開始就進入 parts 模式,那第一題的子題會緊接在題目的題號後面
* 你可以在 \part 指今前或後加上空行,不過它們會被忽略
如果在子題下還有子題,甚至還有更下一層的子題,那你就要使用 \subparts 模式甚至是 \subsubparts 模式,那它就會如你所期望的運作。例如
\begin{questions}
\question

\begin{parts}
\part
What do you do with a drunken sailor?

\part
Is your answer different if it is before noon?
\end{parts}

\question
This is the second question.

\begin{parts}
\part
This is a part.

\part
This is also a part.

\begin{subparts}
\subpart
This is a subpart.

\subpart
This is a periscope.

\subpart
This is a pair of diving planes.

\subpart
\begin{subsubparts}
\subsubpart
This is a subsubpart.

\subsubpart
The lower surface of a diving plane?

\subsubpart
The ocean floor, perhaps?
\end{subsubparts}
\end{subparts}

\part
It’s sad to be apart.
\end{parts}

\question
\begin{parts}

\part
\begin{subparts}
\subpart
This is a subpart.

\subpart
This is another subpart.
\end{subparts}

\part
This is another part.
\end{parts}
\end{questions}


5.2. 題目的配分
每 個 \question, \part, \subpart, \subsubpart 指令都可以加上一個選項,就是題目的配分(在預設中,題目的配分會以括弧框起來,但是也可以用方括號或是方格來替代,這部份的說明要參考 5.2.2.)。而預設中,分數的位置將會放在題目或是子題一開始的位置,不過
* 使用 \pointsinmargin 這個指令可以把他放在左邊界的位置
* 使用 \pointsinrightmargin 這個指令可以把他放在右邊界的位置
* \nopointsinmargin 和 \nopointsinrightmargin 這兩個指令是相同的,都是把配分的
位置放回原本預設的位置
所以的配分都是放在題目的最前面,但是在 5.2.6. 有介紹怎麼把他放在題目的最後一行。而配分的使用方式,舉例如下
\begin{questions}
\question[20]
Why is there air?

\question
What if there were no air?

\begin{parts}
\part[10]
Describe the effect on the balloon industry.

\part[10]
Describe the effect on the aircraft industry.
\end{parts}

\end{questions}
你也可以在這個例子的第一行前面加上 \pointsinmargin 或是 \pointsinrightmargin 這行指令,你就會看到不同的結果。
使用配分時,如果你又要使用中文時,有可能因為編碼的緣故,而變成亂碼,有個應急的方式,就是在題目前加上一個 {~},把中文字和配分隔開,就可以避免亂碼。

5.2.1. 半分
在 歐分考卷的配分上會出現所謂 1/2 分的配分方式,相當於台灣常見的 0.5 分,要印出這樣子的配分,你可以利用 \half 這個指令。直接使用 \half 印出來的會像是電腦一般印出來的"分數"方式,如果你要改成像一般手寫的"分數"寫法,你要在前面加上 \usehorizontalhalf 這個指令。而此時如果又想回復回原來的方式,你可以利用 \uselantedhalf 回復。

5.2.2. 利用括弧(小括號)、方括號(中括號)、或是方框框住配分
如果你比較偏好用方括號來框住分數,而不是預設的括弧,你可以在前面加上 \bracketedpoints 這個指令。或者你也可以用 \boxedpoints 來要求 LaTeX 以方框來框住配分。下面就是一個使用 \backetedpoints 的例子。
\begin{questions}
\backetedpoints
\question[20]
Why is there air?

\question
What if there were no air?

\begin{parts}
\part[10]
Describe the effect on the balloon industry.

\part[10]
Describethe effect on the aircraft industry.
\end{parts}

\end{questions}
當然,\pointsinmargin 或 \pointsinrightmargin 也還是會發生作用的。
正如許多指令都是成對的發揮作用或是取消作用回復原始值一樣,\backetedpoints 與 \boxedpoints 也有取消作用的對應指令,分別是 \nobracketedpoints 與 \noboxedpoints。

5.2.3. 使用"point"的取代字
因為這個 exam 是外國人寫的,所以預設配分的單位是 point,為了要給不同用途的人使用,所以他也提供了改變配分單位的指令,讓你可以把 point 改成你要的字,例如台灣老師常用的"分"。相關的指令如下
* \points 這是用來印出預設的配分單位,這個單位會隨著配分而有單複數(point/points
)的改變
* \pointname{...} 改變配分的單位,例如 \pointname{分} 會把配分的單位變成"分",
以適合台灣老師的使用,而 \pointname{ \points} 會把配分單位改回預設值
* \pointpoints{單數}{複數} 這個指令功能和 \pointname 一樣,只是他有分單複數
* \marksnotpoints 相當於 \pointpoints{mark}{marks}
* \marginpointname{...} 相當於 \pointname{...} 的功能,但是只會對
\pointsinmargin 和 \pointsinrightmargin 發生作用

5.2.4. 使用 marginpointname 與加大邊界
預定的邊界並不大,所以你如果使用 marginpointname 時極有可能會超出邊界,這時候你就會需要利用 \extrawidth 來加大邊界。
dunst: 不過看起來只會縮減左邊的配分的位置

5.2.5. 題目一開始就緊接著子題時的配分方式
要 注意一件事,每行只能有一個配分而且只會印出最後的那個配分。這種事只會出現在 \question 後面緊接著 \begin{parts}、\part 後面緊接著 \begin{subparts}、\subpart 或後面緊接著 \begin{subsubparts}。這是因為像這種狀況,\question 的題和 \part 的題號會出現在同一列。舉例來說
\begin{questions}
\question[10]
\begin{parts}
\part[5]
Who put the ‘‘bop’’ in the ‘‘bop, sh-bop sh-bop’’?

\part[5]
Who put the ‘‘ram’’ in the ‘‘rama, rama ding-dong’’?
\end{parts}
\end{questions}
\question 裡的那個 10 分並不會出現,因為緊接著的那個子題 \part 裡的 5 分是後出現的,所以只會出現那個 5 分。這種狀況對於 \pointsinmargin、\pointsinrightmargin 以及 \nopointsinmargin 的設定下都一樣。但是要注意的是在 \addpoints(詳情見 5.3.) 下,總分卻是 20 分,包括 \question 的 10 分以及兩個子題 \part 的 5 分。雖然 \question 的那 10 分並沒印出來。

5.2.6.
5.2.7.

5.2.8. 當你使用 pointsinmargin 與 pointsinrightmargin 的邊界大小
* 當你使用 \pointsinmargin 時,你可以調整 \marginpointssep 來改變題號與題目左邊 界的距離,預設的距離(5 pt)。指令如下
\setlength{\marginpointssep}{5pt}
* 當你使用 \pointsinrightmargin,你可以調整 \rightpointsmargin 來改變題號左端與 紙張右邊界的距離,預設的距離是(1 cm)。指令如下
\setlength{\rightpointsmargin}{1cm}

5.2.9. 自訂題號
5.2.10.

5.3.
5.4. 利用題號引用特定的題目
其實就是在考卷上常見的"承上題",你可以使用標準的 LaTeX 指令 \label 與 \ref 來引用題目(或子題)。如下面的例子
The first question is question number~\ref{ques:first}.
Question number~\ref{ques:second} has both a good part
(part~\ref{part:good}) and a bad part (part~\ref{part:bad}).

\begin{questions}
\question
\label{ques:first}
This is the first question.

\question
\label{ques:second}
\begin{parts}
\part
\label{part:good}
This is the good part.

\part
\label{part:bad}
This is the \emph{bad} part.
\end{parts}

\question
Is there a question?
\end{questions}
不過,要記得的是,如果你有用到 \ref 及 \label,那你必須要編譯兩次你的文稿,這樣子,你的文件才會正確的指向它所引用的題號。


5.5. 題組裡的特殊結構
這裡的特殊結構就是類似插在題目與題目之間的說明,例如學測的題目中曾出現,因為某兩題是一組的,所以在前面就出現一個說明,並且安插了一個圖表,這時候的說明與圖表並不屬於那一題的內容,此時就要利用這裡的特殊結構。
這 裡有兩個指令可以用來達到我們所要的效果,分別是 \uplevel 與 \fullwidth。這兩個指令讓你設定左邊縮排的範圍。舉例來說,如果你在"子題(parts)"模式下,而你希望在下幾題子題開始前給一些引導,這 些引導的文字應該是獨立出來,和題目有同樣的縮排位置,換句話說,就是要高一"級"。你可以這樣子做
\begin{questions}
\question
Why did you come to Casablanca?

\question
\begin{parts}
\part
Why, Oh why, Oh why, Oh; why did I ever leave Ohio?

\uplevel{The following two parts should be answered in classical
Greek:}

\part
Why do birds sing?

\part
Why do fools fall in love?
\end{parts}

\end{questions}

你會發現 \uplevel{...} 裡的文字會往上跳一級,但是, 如果你不止是要跳一級,而是要直接印一列縮排是接到最左邊的說明,你就要用 \fullwidth{...}。


5.6 當考卷很大張時,為各個部份命名
也 就是說,當你的考卷的題目很多時,你會希望把他切割成幾個部份,並為他命名,讓考卷看起來不要那麼長,也讓寫考卷的人知道自己寫的是那一個部分。此時你有 兩種方法可以達到目的,一個是使用 \fullwidth{...} 和 \uplevel{...}。另一個方法是利用 \part 和 \section 這兩個指令。

5.6.1. 使用 fullwidth 及 uplevel
在考卷上放置段落的名稱,就用 \fullwidth(詳情見 5.5.) 和改變裡面字型的指令就能達到你想要的結果。例如
\begin{questions}
\question
Is there, is there balm in Gilead?

\fullwidth{\Large\bf Essay questions}

\question
Explain how the cooling of matter in the centuries following the big
bang has influenced the British parliamentary system of government.

\fullwidth{\Large\bf Laboratory questions}

\question
In the cabinet below your laboratory bench you will find a single
edged razor blade, several C-clamps, and a bottle of whiskey. Remove
your appendix. Do not suture until your work has been inspected.
\end{questions}

5.6.2. 使用標準的分段指令

5.7.
5.7.1.
5.7.2.
5.7.3.

5.8. 選擇題
有兩種模式可以用在選擇題上:
* choices 模式
* oneparchoices 模式,它會把選項都列在一個段落裡(除非你在模式一開始就留下空位,
不然他會緊連著上一個段落。)
這兩種模式都用大寫的字母(換句話說,就是"A"、"B"、"C"、...)來當做選項的代號,在 5.10. 裡有告訴你要怎麼改變它。

5.8.1. choices 模式
舉例來說
\begin{questions}
\question
One of these things is not like the others; one of these things is not
the same. Which one is different?

\begin{choices}
\choice
John

\choice
Paul

\choice
George

\choice
Ringo

\choice
Socrates
\end{choices}

\end{questions}

5.8.2. Oneparchoices 模式
將 5.8.1. 例子裡的 choices 模式改為 oneparchoices,你會發現原本每個選項佔一列的選擇題會變成所有選項都在同一列。但是要注意的是,在 \begin{oneparchoices} 前有空一行的話,選項才不會緊連著題目。

5.9.
5.9.1
5.9.2
5.9.3

5.10. 自訂題號代號與選擇題的選項代號
要改變題號的代號與選擇題的選項代號,你得要重新定義下面的指令
\thequestion
\thepartno
\thesubpart
\thesubsubpart
\thechoice
(請注意:上表上第二個指令用於 \part 的是 \thepartno 而不是 \thepart,因為 \thepart 這個指令是用於計算 \part 的計數器。)
而這些代號可以使用下列的指令
\arabic 標準的整數代號
\alph 小寫英文字母
\Alph 大寫英文字母
\roman 小寫羅馬數字
\Roman 大寫羅馬數字
\greeknum 希臘字母
這些都可以用於 question、partno、subpart、subsubpart、及 choice。(\greeknum 這個指令被定義於 exam 的文件上,而不是標準的 LaTeX 指令)
舉例來說,題號要用大寫羅馬數字,而子題要用大寫英文字母,你可以這樣下指令
\renewcommand\thequestion{\Roman{question}}
\renewcommand\thepartno{\Alph{partno}}
幫代號做修飾(例如說加上日期、用括弧括起來、或是其它)是可以用下面的指令來決定
\questionlabel
\partlabel
\subpartlabel
\subsubpartlabel
\choicelabel
他們的預設值是這樣子定義的
\newcommand\questionlabel{\thequestion.}
\newcommand\partlabel{(thepartno).}
\newcommand\subpartlabel{\thesubpart.}
\newcommand\subsubpartlabel{\thesubsubpart)}
\newcommand\choicelabel{\thechoice.}
你可以利用 \recommand 重新去定義它。例如你想把選擇題的選項代號改成 (A)、(B)、...,你可以像這樣子定義
\renewcommand\choicelabel{(\thechoice)}

沒有留言: