置頂介紹文

這裡主要放一些關於數學和 LaTeX 的文章, 文章內的檔案一律用 xelatex 編譯而成。
如果你想下載我的 tex 檔回去修改編譯, 請將 preamble.7z 解壓縮後和 tex 檔放在同一個資料夾中即可編譯。
部落格內的文章也有部份是網路或書籍中的資料經過統整編輯而成, 如有侵權請告知。
有任何問題也歡迎留言或 E-mail 給我。

2016年6月29日 星期三

用 LaTeX 做數學考卷 (五) : 填充題與選填題

這篇介紹利用計數器來做填充題的題目, 讓答案欄能自動編號以及製作選填題的題型。

......
%填充題答案欄 \ansfill
\newcounter{fillcounter}
\setcounter{fillcounter}{1}

\newcommand{\ansfill}{\;\underline{\hspace{0.3cm}({\arabic{fillcounter}})\hspace{0.3cm}}\addtocounter{fillcounter}{1} }

\usepackage{tikz}
%選填題圍繞數字設定 \nc
\usepackage{etoolbox}
\newcommand{\circled}[2][]{%
\tikz[baseline=(char.base)]{%
\node[shape = circle, draw, inner sep = 0.5pt]
(char) {\phantom{\ifblank{#1}{#2}{#1}}};%
\node at (char.center) {\makebox[0pt][c]{#2}};}}
\robustify{\circled}
\newcounter{circlecounter}
\setcounter{circlecounter}{1}
\newcommand{\nc}{{\small \circled[00]{%

\arabic{circlecounter}\addtocounter{circlecounter}{1}}}}
......

\begin{document}
\begin{enumerate}
\item 選填題
\begin{enumerate}
\item 請有理化 $\frac{1}{\sqrt{2}-1}=\underline{\sqrt{\nc}+\nc}$
\item 設 $f(x)$ 為一實係數多項式, 若 $f(3+4i)=4-7i$, 則 $f(3-4i)=\underline{\nc+\nc\; i}$。
\end{enumerate}
\item 填充題
\begin{enumerate}
\item 設一二次函數 $f(x)=x^2+4x-1$, 則當 $x=$\ansfill 時, 有最大值 \ansfill。
\item 有一圓方程式為 $x^2+(y-3)^2=9$, 則此圓圓心為 \ansfill, 半徑為 \ansfill。
\end{enumerate}
\end{enumerate}

\end{document}


\newcounter{fillcounter}: 設定新計數器
\setcounter{fillcounter}{1} : 設定這個計數器從 1 開始數

\underline{\hspace{0.3cm}({\arabic{fillcounter}})\hspace{0.3cm}}: 填充題的格子
\underline 底線 
\hspace{0.3cm}留一小段空白 
({\arabic{fillcounter}}) 將 fillcounter 這個計數器用阿拉伯數字顯示, 並放在 () 中間

\addtocounter{fillcounter}{1}: 最後將 fillcounter 這個計數器加 1

然後只要在要問題的空格打上 \ansfill 就可以了。

選填題的圍繞字元基本上用 tikz 畫出圓, 然後用計數器將數字填入, 事實上使用的機會也很少, 這裡只說明這一行: \newcommand{\nc}{{\small \circled[00]{% 這裡的 \small 是改變字體的大小, 如果覺得太大, 一樣可以用 \footnotesize, \scriptsize 甚至是 \tiny 讓字體縮小。

1 則留言:

  1. 你好,想請教關於選填題畫圈的問題

    因為現在108課綱開始實施卷卡合一,變成選填題的形式不太一樣了

    如果第11題有三個格子要寫,就變成11-1 11-2 11-3

    這樣子的話是要再多增加計數器嗎?

    如果這樣子,有辦法讓第一個計數器跟著題號走嗎?還是說就從\setcounter這邊修正就好?

    感謝你~

    回覆刪除