我正在尝试使用 AMC 制作作业表,为了节省一些问题的空间,我使用了多列
这是 MWE
\documentclass[a4paper]{article}
\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\usepackage[version=4]{mhchem}
\usepackage{amsmath,amssymb}
\usepackage{multicol}
% \TBmulticolcolumns
\usepackage{xspace}
\usepackage{siunitx}
\usepackage{tasks}
\usepackage{diffcoeff}
\usepackage{mathtools}
\usepackage{booktabs}
% \usepackage{chem}
% \input{chem.sty}
\RequirePackage{etex}
\usepackage[box,completemulti,nopage,noshufflegroups,separateanswersheet,noshuffle]{automultiplechoice}
\everymath{\displaystyle}
\begin{document}
\AMCrandomseed{1237893}
\AMCboxStyle{shape=oval}
\def\AMCformQuestion#1{{\sc Q #1:}}
\setdefaultgroupmode{withoutreplacement}
\element{general}{
\begin{question}{nb-ue}
How many different states were members of the European Union in Jan. 2009?
\begin{multicols*}{2}
\begin{choices}
\wrongchoice{15}
\wrongchoice{21}
\correctchoice{27}
\wrongchoice{31}
\end{choices}
\end{multicols*}
\end{question}
}
% QUESTIONS ON NUMBER OFATOMS AND MOLAR MASS
\element{easy}{
\begin{question}{Q.5}
1.2 gm of Mg (At. mass 24) will produce MgO equal to
\begin{multicols}{2}
\begin{choices}
\correctchoice{ (A) 0.05 mol }
\wrongchoice{ (B) 40 gm }
\wrongchoice{ (C) 40 mg }
\wrongchoice{ (D) 4 gm }
\end{choices}
\end{multicols}
\end{question}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%
%Nothing is relevant to my problem below this
%%%%%%%%%%%%%%%%%%%%%%%
\onecopy{1}{
%%% beginning of the test sheet header:
\noindent{\bf QCM \hfill TEST}
\vspace*{.5cm}
\begin{minipage}{.4\linewidth}
\centering\large\bf Test\\ Examination on Jan. 1st, 2008
\end{minipage}
\begin{center}\em
Duration : 10 minutes.
No documents allowed. The use of electronic calculators is forbidden.
Questions using the sign \multiSymbole{} may have
zero, one or several correct answers. Other questions have a single correct answer.
Negative points may be attributed to \emph{very
bad} answers.
\end{center}
\vspace{1ex}
%%% end of the header
\insertgroup{general}
\insertgroup{easy}
\AMCcleardoublepage
% \AMCaddpagesto{3}
\AMCformBegin
%%% beginning of the answer sheet header
{\large\bf Answer sheet:}
\hfill \namefield{\fbox{
\begin{minipage}{.5\linewidth}
Firstname and lastname:
\vspace*{.5cm}\dotfill
\vspace*{1mm}
\end{minipage}
}}
\begin{center}
\bf\em Answers must be given exclusively on this sheet:
answers given on the other sheets will be ignored.
\end{center}
%%% end of the answer sheet header
\AMCform
% \AMCaddpagesto{5}
}
\end{document}
输出如下所示
我的问题是选项对齐为
交流电
屋宇署
而我想要的是对齐的选项
AB
光盘
关于同一主题已经出现了几个问题,但是没有一个能够帮助我。
如何使用 multicol 实现此效果?或者,如果使用 multicol 太困难,我如何使用任务来实现?
编辑:添加较小的 MWE。
\documentclass[a4paper]{article}
\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[version=4]{mhchem}
\usepackage{amsmath,amssymb}
\usepackage{multicol}
\usepackage{xspace}
\usepackage{siunitx}
\usepackage{tasks}
\usepackage{booktabs}
\usepackage[box,completemulti,nopage,noshufflegroups,separateanswersheet,noshuffle]{automultiplechoice}
\begin{document}
\AMCrandomseed{1237893}
\setdefaultgroupmode{withoutreplacement}
\element{general}{
\begin{question}{nb-ue}
How many different states were members of the European Union in Jan. 2009?
\begin{multicols}{2}
\begin{choices}
\wrongchoice{15}
\wrongchoice{21}
\correctchoice{27}
\wrongchoice{31}
\end{choices}
\end{multicols}
\end{question}
}
\element{general}{
\begin{question}{Q.5}
1.2 gm of Mg (At. mass 24) will produce MgO equal to
\begin{multicols}{2}
\begin{choices}
\correctchoice{ (A) 0.05 mol }
\wrongchoice{ (B) 40 gm }
\wrongchoice{ (C) 40 mg }
\wrongchoice{ (D) 4 gm }
\end{choices}
\end{multicols}
\end{question}}
\onecopy{1}{
\insertgroup{general}
\AMCcleardoublepage
\AMCformBegin
\AMCform
}
\end{document}
请参考较小的 MWE
答案1
选项 1:手动操作
在第一个例子中,我使用choiceshoriz
环境来水平打印所有内容。
在第二个示例中,我使用choicescustom
环境和一些技巧来打印两列。请注意,这仅适用于简短答案。我所做的是定义一个新的布尔切换,用于跟踪我是否设置了奇数列。每次 AMC 打印一个项目时,切换都会更改值,在偶数列,我们会打印换行符。格式化完全由和完成\hspace
,\rlap
因此太长的文本会叠印。
\documentclass[a4paper]{article}
\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[version=4]{mhchem}
\usepackage{amsmath,amssymb}
\usepackage{xspace}
\usepackage{siunitx}
\usepackage{booktabs}
\usepackage[box,completemulti,nopage,noshufflegroups,separateanswersheet,noshuffle]{automultiplechoice}
\newif\ifAMCoddcolumn
\AMCoddcolumntrue
\def\AMCbeginAnswer{\vspace{\topsep}\par\AMCoddcolumntrue}
\def\AMCendAnswer{\par}
\def\AMCanswer#1#2{\hspace*{0.1\textwidth}\rlap{#1 #2}\hspace*{0.35\textwidth}\ifAMCoddcolumn\AMCoddcolumnfalse\else\par\AMCoddcolumntrue\fi}
\begin{document}
\AMCrandomseed{1237893}
\setdefaultgroupmode{withoutreplacement}
\element{general}{
\begin{question}{nb-ue}
How many different states were members of the European Union in Jan. 2009?
\begin{choiceshoriz}
\wrongchoice{15}
\wrongchoice{21}
\correctchoice{27}
\wrongchoice{31}
\end{choiceshoriz}
\end{question}
}
\element{general}{
\begin{question}{Q.5}
1.2 gm of Mg (At. mass 24) will produce MgO equal to
\begin{choicescustom}
\correctchoice{ (A) 0.05 mol }
\wrongchoice{ (B) 40 gm }
\wrongchoice{ (C) 40 mg }
\wrongchoice{ (D) 4 gm }
\end{choicescustom}
\end{question}}
\onecopy{1}{
\insertgroup{general}
\AMCcleardoublepage
\AMCformBegin
\AMCform
}
\end{document}
(旧版本的屏幕截图,没有\vspace{\topsep}
在问题和答案之间添加一些垂直填充。)
选项 2:使用任务
要使用tasks
,由于tasks
处理列表的特殊方式,语法有点令人惊讶。你必须把\begin{tasks}...
里面 \begin{choicescustom}
并手动插入\task
。(本质上,您希望先让tasks
进程拆分参数和放置,然后再让 AMC 打印 MC 答案。)
\documentclass[a4paper]{article}
\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[version=4]{mhchem}
\usepackage{amsmath,amssymb}
\usepackage{xspace}
\usepackage{siunitx}
\usepackage{booktabs}
\usepackage{tasks}
\usepackage[box,completemulti,nopage,noshufflegroups,separateanswersheet,noshuffle]{automultiplechoice}
\def\AMCanswer#1#2{#1 #2}
\begin{document}
\AMCrandomseed{1237893}
\setdefaultgroupmode{withoutreplacement}
\element{general}{
\begin{question}{nb-ue}
How many different states were members of the European Union in Jan. 2009?
\begin{choiceshoriz}
\wrongchoice{15}
\wrongchoice{21}
\correctchoice{27}
\wrongchoice{31}
\end{choiceshoriz}
\end{question}
}
\element{general}{
\begin{question}{Q.5}
1.2 gm of Mg (At. mass 24) will produce MgO equal to
\begin{choicescustom}
\begin{tasks}[label={}](2)
\task \correctchoice{ (A) 0.05 mol }
\task \wrongchoice{ (B) 40 gm }
\task \wrongchoice{ (C) 40 mg }
\task \wrongchoice{ (D) 4 gm }
\end{tasks}
\end{choicescustom}
\end{question}}
\onecopy{1}{
\insertgroup{general}
\AMCcleardoublepage
\AMCformBegin
\AMCform
}
\end{document}
答案2
在 @willie answer 的帮助下,我设法解决了这个问题。对于其他可能寻找它的人来说,这是我的解决方案。“任务”效果很好,它还帮助我解决了排列选项的问题。这是我的最终代码和示例输出。
\documentclass[a4paper]{article}
\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[version=4]{mhchem}
\usepackage{amsmath,amssymb}
\usepackage{xspace}
\usepackage{siunitx}
\usepackage{booktabs}
\usepackage{tasks}
\usepackage[box,completemulti,nopage,noshufflegroups,separateanswersheet,noshuffle]{automultiplechoice}
\def\AMCanswer#1#2{#1 #2}
\begin{document}
\AMCrandomseed{1237893}
\setdefaultgroupmode{withoutreplacement}
\element{general}{
\begin{question}{nb-ue}
This is a questoin where all the options are in a single column. useful when the answer or choices are long and multiple would not fit in a single row!
\begin{choicescustom}
\begin{tasks}[label={}](2)
\task* \wrongchoice{15}
\task* \wrongchoice{21}
\task* \correctchoice{27}
\task* \wrongchoice{31}
\end{tasks}
\end{choicescustom}
\end{question}
}
\element{general}{
\begin{question}{Q.5}
This is a question where the options are present in two rows.
\begin{choicescustom}
\begin{tasks}[label={}](2)
\task \correctchoice{ (A) 0.05 mol }
\task \wrongchoice{ (B) 40 gm }
\task \wrongchoice{ (C) 40 mg }
\task \wrongchoice{ (D) 4 gm }
\end{tasks}
\end{choicescustom}
\end{question}}
\element{general}{
\begin{question}{nb-ue2}
This is a question where all options are present in a single row. Useful if the options are very small.
Also you will Notice the all the options including the previous two questions line up well.
\begin{choicescustom}
\begin{tasks}[label={}](4)
\task \wrongchoice{15}
\task \wrongchoice{21}
\task \correctchoice{27}
\task \wrongchoice{31}
\end{tasks}
\end{choicescustom}
\end{question}
}
\onecopy{1}{
\insertgroup{general}
\AMCcleardoublepage
\AMCformBegin
\AMCform
}
\end{document}
我认为我必须提及的唯一重要点是choicescustom
在使用任务时使用。
这是相同的输出。如您所见,选项排列得很好。我还没有对图像进行过相同的尝试,但我不认为这会带来问题。