我很新的乳膠,我試圖創建一個格式的考試問題,將盡可能少寫乳膠。 目前我寫了這個代碼:嵌入命令到參數環境和環境
\documentclass{article}
%the question environment wrapping every exam questions
\newenvironment{q}[2] {
\newcounter{answerCounter} %used for display of answer number with question
\setcounter{answerCounter}{0}
\newcommand{a}[1] {
\item a\value{answerCounter}: ##1
%I used double hyphen on previous line because i'm within an environment
\addtocounter{answerCounter}{1}
}
\item q#1: #2
%the 1st param of q (the environment) is the question number, 2nd is the question itself
\begin{itemize}
} { \end{itemize} }
\begin{document}
\begin{itemize}
\begin{q}{1}{to be or not to be?}
\a{to be}
\a{not to be}
\end{q}
\begin{q}{2}{are you john doe?:}
\a{No i'm Chuck Norris}
\a{maybe}
\a{yes}
\end{q}
\end{itemize}
\end{document}
,我希望它顯示這樣:
但是當我做pdflatex exam.tex
我得到以下第2個錯誤(有更多的,但我不想讓你知道信息):
! Missing control sequence inserted.
<inserted text>
\inaccessible
l.21 \begin{q}{1}{to be or not to be?}
?
(/usr/share/texlive/texmf-dist/tex/latex/base/omscmr.fd)
! LaTeX Error: Command \to be unavailable in encoding OT1.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.22 \a{to be}
?
我有沒有調用/定義我的環境和命令錯?謝謝。