我正在处理一个包含类的文档article
,我想在其中添加多项选择题。这是否很难做到,以至于我应该将其更改为exam
类?如果不难,我该如何实现?
非常感谢任何帮助!
答案1
如果您只是偶尔想要问多项选择题,那么考试课可能有点过头了。这是一个完整的 LaTeX 文件,它定义了环境choices
和oneparchoices
环境,您可以使用它来列出选项。(我假设您会使用环境enumerate
来列出问题。)
\documentclass{article}
%--------------------------------------------------------------------
%--------------------------------------------------------------------
\newcounter{choice}
\renewcommand\thechoice{\Alph{choice}}
\newcommand\choicelabel{\thechoice.}
\newenvironment{choices}%
{\list{\choicelabel}%
{\usecounter{choice}\def\makelabel##1{\hss\llap{##1}}%
\settowidth{\leftmargin}{W.\hskip\labelsep\hskip 2.5em}%
\def\choice{%
\item
} % choice
\labelwidth\leftmargin\advance\labelwidth-\labelsep
\topsep=0pt
\partopsep=0pt
}%
}%
{\endlist}
\newenvironment{oneparchoices}%
{%
\setcounter{choice}{0}%
\def\choice{%
\refstepcounter{choice}%
\ifnum\value{choice}>1\relax
\penalty -50\hskip 1em plus 1em\relax
\fi
\choicelabel
\nobreak\enskip
}% choice
% If we're continuing the paragraph containing the question,
% then leave a bit of space before the first choice:
\ifvmode\else\enskip\fi
\ignorespaces
}%
{}
%--------------------------------------------------------------------
%--------------------------------------------------------------------
%--------------------------------------------------------------------
\begin{document}
\begin{enumerate}
\item One of these things is not like the others; one of these things
is not the same. Which one doesn't belong?
\begin{choices}
\choice George
\choice Paul
\choice John
\choice Ringo
\choice Socrates
\end{choices}
\item What was the color of George Washinton's white horse?
\begin{choices}
\choice Green
\choice Yellow
\choice White
\end{choices}
\item One of these things is not like the others; one of these things
is not the same. Which one doesn't belong?
\begin{oneparchoices}
\choice George
\choice Paul
\choice John
\choice Ringo
\choice Socrates
\end{oneparchoices}
\item What was the color of George Washinton's white horse?
\begin{oneparchoices}
\choice Green
\choice Yellow
\choice White
\end{oneparchoices}
\item One of these things is not like the others; one of these things
is not the same. Which one doesn't belong?
\begin{oneparchoices}
\choice George
\choice Paul
\choice John
\choice Ringo
\choice Socrates
\end{oneparchoices}
\item What was the color of George Washinton's white horse?
\begin{oneparchoices}
\choice Green
\choice Yellow
\choice White
\end{oneparchoices}
\end{enumerate}
\end{document}
如果您希望choices
环境的缩进更小,您可以减少\leftmargin
。
答案2
如果你想把 QCM 放在你已有的表中alterqcm
,这是一个 TeXLive 包
\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[upright]{fourier}%withot fourier symb = $\altersquare$
\usepackage{alterqcm}
\parindent0pt
\begin{document}
\begin{alterqcm}[lq=8cm,language=english]
\AQquestion{Question}{%
{Proposition 1},
{Proposition 2},
{Proposition 3}}
\AQquestion{Question}{%
{Proposition 1},
{Proposition 2},
{Proposition 3}}
\end{alterqcm}
\end{document}
如果没有“fourier”,则需要使用带有符号的字体\square
,或者可以使用选项symb = $\altersquare$
。在下一个版本中,将可以添加水平答案
答案3
对于非常简单且可移植的(不同的文档类别等)解决方案,可以执行以下操作:
\documentclass{article}
\usepackage{wasysym} % contains the desired symbols
\begin{document}
\begin{itemize}
\item[\Square] Open question
\item[\XBox] Ticked question
\item[\CheckedBox] Checked question
\end{itemize}
\end{document}
或者,减少样板代码的数量:
\documentclass{article}
\usepackage{wasysym} % contains the desired symbols
\usepackage{enumitem} % allows for itemize label specification
\begin{document}
\begin{itemize}[label=\Square]
\item Open question
\item Open question 2
\item Open question 3
\end{itemize}
\end{document}
答案4
这是我们为部门组织的高中数学竞赛排版试卷而创建的简短软件包。它旨在让输入问题变得非常简单,软件包主要负责格式和间距,用户只需输入问题即可。它非常不灵活,每个问题只允许有 5 个选项,但我将其作为示例,供您参考。
% File: mchoice.sty
%
% Author: Jan Hlavacek ([email protected])
% Changes:
% v. 0.1 initial version
% v. 1.1 automatic markings of correct answer
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{mchoice}[2007/01/07 Package for typeseting simple multiple
choice tests, version 1.1]
\makeatletter
\newif\ifsolution
\solutionfalse
\DeclareOption{solutions}{\solutiontrue}
\ProcessOptions\relax
\newwrite\MCwrite
\AtBeginDocument{\immediate\openout\MCwrite=\jobname.mca}
\newskip\mcitemsep % glue separating the (.) from the text of each option (can be modified by user)
\mcitemsep=.5em
\newskip\mcinteritemskip % glue that goes between items on each line (can be modified by user)
\mcinteritemskip=2em
\newcommand{\NOTAtext}{None of the above} % Use \renewcommand to change this
\newcounter{mccount}
\def\mcitembox(#1)#2{\hbox{\textbf{(#1)}\hspace\mcitemsep#2}}
\newbox\mcnotabox
\AtBeginDocument{\setbox\mcnotabox\mcitembox(e){\NOTAtext}}
% Identify correct solution
\newtoks\MCSolutions
\MCSolutions={}
\newcounter{mcs@lcount}
\def\isc@rrect{%
\addtocounter{mcs@lcount}{1}%
\def\n@xt{\ifx\n@@xt!\expandafter\c@rrect\fi}%
\futurelet\n@@xt\n@xt}
\def\c@rrect#1{\edef\@ct{\global\MCSolutions={\the\MCSolutions
\Alph{mcs@lcount}}}\@ct}
\newcommand{\MultChoiceNOTA}[5][0]{%
\setcounter{mcs@lcount}{0}
\MCSolutions={}
\ifnum #1=0
\multch@icenota{\isc@rrect#2}{\isc@rrect#3}{\isc@rrect#4}{\isc@rrect#5}
\else
\multch@iceloosenota{\isc@rrect#2}{\isc@rrect#3}{\isc@rrect#4}{\isc@rrect#5}
\fi
\edef\t@st{\the\MCSolutions}\edef\t@@st{}
\ifx\t@st\t@@st\global\MCSolutions={E}\fi
\immediate\write\MCwrite{\the\MCSolutions}}
\newcommand{\multch@icenota}[4]{%
\setbox0\mcitembox(a){#1}%
\setbox2\mcitembox(b){#2}%
\setbox4\mcitembox(c){#3}%
\setbox6\mcitembox(d){#4}%
\setbox8\copy\mcnotabox%
%
% Find the maximal length:
%
\dimen0=\wd0 \ifdim\wd2>\dimen0 \dimen0=\wd2 \fi\ifdim\wd4>\dimen0
\dimen0=\wd4 \fi\ifdim\wd6>\dimen0 \dimen0=\wd6 \fi%
%
% If the resulting length is more than \textwidth, we have to unbox the items and typeset them differently:
%
\ifdim\dimen0>\textwidth
\bgroup%
\begin{list}{\textbf{(\alph{mccount})}}{\usecounter{mccount}\setlength\labelsep\mcitemsep\setbox0=\hbox{\textbf{(a)}\hspace\mcitemsep}\setlength\labelwidth{\wd0}}
\item #1
\item #2
\item #3
\item #4
\item \NOTAtext
\end{list}
\egroup%
\else
%
% Now check the NOTA box. If it is shorter than the rest, make it match. If
% it is not much longer, make the rest match it.
%
\dimen2=\dimen0
\advance\dimen2 by .5in
\ifdim\wd8<\dimen0 \wd8=\dimen0 \else
\ifdim\wd8<\dimen2 \dimen0=\wd8 \fi\fi
%
% Make all the boxes of the same length:
%
\wd0=\dimen0 \wd2=\dimen0 \wd4=\dimen0 \wd6=\dimen0%
\bgroup%
\par%
\openup\baselineskip
\tolerance=10000
\noindent\box0\hskip\mcinteritemskip\penalty9000\box2\hskip\mcinteritemskip\penalty6000\box4\hskip\mcinteritemskip\penalty3000\box6\hskip\mcinteritemskip\penalty1000\box8\hfill\par\egroup%
\fi\medskip}
\newcommand{\multch@iceloosenota}[4]{%
\setbox0\mcitembox(a){#1}%
\setbox2\mcitembox(b){#2}%
\setbox4\mcitembox(c){#3}%
\setbox6\mcitembox(d){#4}%
\setbox8\copy\mcnotabox%
\bgroup%
\par%
\openup\baselineskip
\tolerance=10000
\raggedright
\noindent\box0\hskip\mcinteritemskip\quad\penalty9000\box2\hskip\mcinteritemskip\quad\penalty6000\box4\hskip\mcinteritemskip\quad\penalty3000\box6\hskip\mcinteritemskip\quad\penalty1000\box8\quad\par\egroup%
\medskip}
\newcommand{\MultChoice}[6][0]{%
\setcounter{mcs@lcount}{0}
\MCSolutions={}
\ifnum #1=0
\multch@ice{\isc@rrect#2}{\isc@rrect#3}{\isc@rrect#4}{\isc@rrect#5}{\isc@rrect#6}
\else
\multch@ice{\isc@rrect#2}{\isc@rrect#3}{\isc@rrect#4}{\isc@rrect#5}{\isc@rrect#6}
%currently there is no loose form of regular multiple choice.
\fi
\edef\t@st{\the\MCSolutions}\edef\t@@st{}
\ifx\t@st\t@@st\global\MCSolutions={X}\fi
\immediate\write\MCwrite{\the\MCSolutions}}
\newcommand{\multch@ice}[5]{%
\setbox0\mcitembox(a){#1}%
\setbox2\mcitembox(b){#2}%
\setbox4\mcitembox(c){#3}%
\setbox6\mcitembox(d){#4}%
\setbox8\mcitembox(e){#5}%
%
% Find the maximal length:
%
\dimen0=\wd0 \ifdim\wd2>\dimen0 \dimen0=\wd2 \fi\ifdim\wd4>\dimen0
\dimen0=\wd4 \fi\ifdim\wd6>\dimen0 \dimen0=\wd6 \fi\ifdim\wd8>\dimen0
\dimen0=\wd8 \fi%
%
% If the resulting length is more than \textwidth, we have to unbox the items and typeset them differently:
%
\ifdim\dimen0>\textwidth
\bgroup%
\begin{list}{\textbf{(\alph{mccount})}}{\usecounter{mccount}\setlength\labelsep\mcitemsep\setbox0=\hbox{\textbf{(a)}\hspace\mcitemsep}\setlength\labelwidth{\wd0}}
\item #1
\item #2
\item #3
\item #4
\item #5
\end{list}
\egroup%
\else
%
% Make all the boxes of the same length:
%
\wd0=\dimen0 \wd2=\dimen0 \wd4=\dimen0 \wd6=\dimen0 \wd8=\dimen0%
\bgroup%
\par%
\openup\baselineskip
\tolerance=10000
\noindent\box0\hskip\mcinteritemskip\penalty9000\box2\hskip\mcinteritemskip\penalty6000\box4\hskip\mcinteritemskip\penalty3000\box6\hskip\mcinteritemskip\penalty1000\box8\hfill\par\egroup%
\fi\medskip}
\def\solutiontext#1.{\textsc{Solution~}\textbf{(\lowercase{#1})}:}
\newenvironment{solution}{\ifsolution\par\noindent\expandafter\solutiontext\the\MCSolutions.%
\else\bgroup\setbox0\vbox\bgroup\fi}{\ifsolution\par\else\egroup\egroup\fi\vspace{\fill}}
\def\solutionm@rk#1.{\textbf{(\lowercase{#1})}}
\def\lastsolution{\expandafter\solutionm@rk\the\MCSolutions.}
\makeatother
你可以像这样使用它:
\documentclass{article}
\usepackage[solutions]{mchoice}
\begin{document}
\begin{enumerate}
\item How many different ways are there to pay a $\$9.75$ bill if only
dimes and quarters are available?
\MultChoiceNOTA% "NOTA" means "none of the above" will the fifth choice
{39}
{19}
{!20}% The correct answer is marked with !
{40}
\begin{solution}
We need to find the number of non-negative integer solutions of the
equation $10x + 25y = 975$, or $2x + 5y = 195$, or $2x = 195 - 5y$.
Because the right hand side is divisible by $5$, $x$ must also be
divisible by $5$, so $x=5d$ for some non-negative integer $d$. Then
the equation becomes $10d = 195 - 5y$ or $2d = 39 - y$. So the number
of solutions will be the number of non-negative even integers less
than or equal to $39$. There are $\frac{39+1}{2} = 20$ such numbers.
\end{solution}
\item The digits of the whole numbers from $1$ to $99$ are concatenated in
order to form the number $N$:
\[N = 1234567891011121314\dots979899\]
Which of the following is true?
\MultChoiceNOTA%
{$N$ is divisible by $3$ but not by $6$ and $9$}
{$N$ is divisible by $3$ and $6$ but not by $9$}
{!$N$ is divisible by $3$ and $9$ but not by $6$}
{$N$ is not divisible by any of $3$, $6$ or $9$}
\begin{solution}
The sum of the digits on $N$ is $10(1 + 2 + 3 + \dots + 9) + 10(1 + 2 +
3 + \dots + 9) = 20\cdot 45 = 900$ which is
divisible ny $3$ and $9$, so $N$ is divisible by both $3$ and $9$.
$N$ is not divisible by $2$ since it ends in $9$, so $N$ cannot be
divisible by $6$.
\end{solution}
\item A circular table has exactly $60$ chairs around it. There are $N$
people seated around the table. The next person coming to the table will
have to be seated next to an occupied seat. Find the smallest possible
value of $N$.
\MultChoice%
{$15$}
{!$20$}
{$30$}
{$40$}
{$58$}
\begin{solution}
For the next person to have to sit next to an occupied seat, there
cannot be three consecutive chairs currently unoccupied (otherwise
the next person would simply sit in the middle of the three empty
chairs). Therefore for every three consecutive chairs at least one of them
has to be occupied. Since we are looking for the smallest $N$,
exactly one of the three will have to be occupied, and each two
people will have to have two empty seats between them. Therefore the
number of people sitting at the table is $1/3$ of the number of
seats, or $20$ people.
\end{solution}
\end{enumerate}
\end{document}
该软件包还会自动创建一个.mca
文件(多项选择答案),其中包含所有问题的正确答案列表。我们在自动评分脚本中使用它。