我已在同一标题下使用了其他人在上一个问题中给出的代码。
我正是想产生所有四个选项,例如
(a)
(b)
(c)
(d)
由于选项的长度很大,因此下面给出的代码无法正常工作,无法达到我想要的结果。
请帮我。
\documentclass[12pt,a4paper]{exam}
\usepackage{amsmath,amsthm,amsfonts,amssymb,dsfont}
\setlength\parindent{0pt}
%usage \choice{ }{ }{ }{ }
%(A)(B)(C)(D)
\newcommand{\fourch}[4]{
\par
\begin{tabular}{*{4}{@{}p{0.23\textwidth}}}
(a)~#1 & (b)~#2 & (c)~#3 & (d)~#4
\end{tabular}
}
%(A)(B)
%(C)(D)
\newcommand{\twoch}[4]{
\begin{tabular}{*{2}{@{}p{0.46\textwidth}}}
(a)~#1 & (b)~#2
\end{tabular}
\par
\begin{tabular}{*{2}{@{}p{0.46\textwidth}}}
(c)~#3 & (d)~#4
\end{tabular}
}
%(A)
%(B)
%(C)
%(D)
\newcommand{\onech}[4]{
\par
(a)~#1 \par (b)~#2 \par (c)~#3 \par (d)~#4
}
\newlength\widthcha
\newlength\widthchb
\newlength\widthchc
\newlength\widthchd
\newlength\widthch
\newlength\tabmaxwidth
\setlength\tabmaxwidth{0.96\textwidth}
\newlength\fourthtabwidth
\setlength\fourthtabwidth{0.25\textwidth}
\newlength\halftabwidth
\setlength\halftabwidth{0.5\textwidth}
\newcommand{\choice}[4]{%
\settowidth\widthcha{AM.#1}\setlength{\widthch}{\widthcha}%
\settowidth\widthchb{BM.#2}%
\ifdim\widthch<\widthchb\relax\setlength{\widthch}{\widthchb}\fi%
\settowidth\widthchb{CM.#3}%
\ifdim\widthch<\widthchb\relax\setlength{\widthch}{\widthchb}\fi%
\settowidth\widthchb{DM.#4}%
\ifdim\widthch<\widthchb\relax\setlength{\widthch}{\widthchb}\fi%
\ifdim\widthch<\fourthtabwidth
\fourch{#1}{#2}{#3}{#4}
\else\ifdim\widthch<\halftabwidth
\ifdim\widthch>\fourthtabwidth
\twoch{#1}{#2}{#3}{#4}
\else
\onech{#1}{#2}{#3}{#4}
\fi
\fi\fi
}
\begin{document}
\begin{questions}
\question If $a = 3 + i$ and $z = 2 - 3i$ then the points on the Argand diagram
representing az, 3az and - az are
\choice{Vertices of a right angled triangle}{ Vertices of an equilateral
triangle}{Vertices of an isosceles triangle}{Collinear}
\question If z represents a complex number then $\arg (z) + \arg\left(\bar z\right)$ is
\choice{$\dfrac{\pi}{4}$}{$\dfrac{\pi}{2}$}{0}{$\dfrac{\pi}{6}$}
\question If the amplitude of a complex number is $\dfrac{\pi}{2}$ then the number is
\choice{ purely imaginary}{purely real}{0}{neither real nor imaginary}
\question The value of $i + i^{22} + i^{23} + i^{24} + i^{25}$ is
\choice{i}{-i}{1}{-1}
\question The volume generated by
rotating the triangle with vertices at
(0, 0), (3, 0) and (3, 3) about x-axis is
\choice{$18\pi$}{$2\pi$}{$36\pi$}{$9\pi$}\end{questions}
\end{document}
\end{document}
我已将上述标题中上一个问题中的上述代码用于此。
答案1
更新 Gonzalo Medina 的评论以调整格式
我会直接使用包提供的问题类型exam
,而不使用您定义的命令。请注意可用的两个环境choices
和oneparchoices
。
\documentclass[12pt,a4paper]{exam}
\usepackage{amsmath,amsthm,amsfonts,amssymb,dsfont}
\renewcommand\choicelabel{(\alph{choice})}
\renewcommand\choiceshook{\setlength{\leftmargin}{20pt}}
\begin{document}
\begin{questions}
\question If $a = 3 + i$ and $z = 2 - 3i$ then the points on the Argand diagram
representing az, 3az and - az are
\begin{choices}
\choice Vertices of a right angled triangle
\choice Vertices of an equilateral triangle
\choice Vertices of an isosceles triangle
\choice Collinear
\end{choices}
\question If z represents a complex number then $\arg (z) + \arg\left(\bar z\right)$ is
\begin{choices}
\choice $\dfrac{\pi}{4}$
\choice $\dfrac{\pi}{2}$
\choice 0
\choice $\dfrac{\pi}{6}$
\end{choices}
\question If the amplitude of a complex number is $\dfrac{\pi}{2}$ then the number is
\begin{choices}
\choice purely imaginary
\choice purely real
\choice 0
\choice neither real nor imaginary
\end{choices}
\question The value of $i + i^{22} + i^{23} + i^{24} + i^{25}$ is
\begin{oneparchoices}
\choice i
\choice -i
\choice 1
\choice -1
\end{oneparchoices}
\question The volume generated by
rotating the triangle with vertices at (0, 0), (3, 0) and (3, 3) about x-axis is
\begin{oneparchoices}
\choice $18\pi$
\choice $2\pi$
\choice $36\pi$
\choice $9\pi$
\end{oneparchoices}
\end{questions}
\end{document}
\end{document}