如何使用考试包创建标题答案?

如何使用考试包创建标题答案?

我已经使用这个地方很长时间了,并且搜索了几种关于正确输入 latex 的解决方案。

我尝试写一份简单的试卷,类似于@Phil Hirschorn 的回答。我在使用多项选择题测试制作 2 列时遇到了问题。

我真的很喜欢做一个简单的考试,看起来像这样:

在此处输入图片描述

当我使用时\showallanswers我们打印这个标题

在此处输入图片描述

有什么建议吗?

\documentclass[11pt,a4paper,twocolumn]{考试}
\usepackage{amsmath,amsthm,amsfonts,amssymb,dsfont}
\usepackage{ifthen}
\usepackage{多列}

% 收集答案。未修改自 Phil Hirschorn 的答案“单独”显示问题的解决方案 \newbox\allanswers \setbox\allanswers=\vbox{}

\newenvironment{答案} {% \global\setbox\allanswers=\vbox\bgroup \unvbox\所有答案 }% {% \重大突破 \egroup }

\newcommand{\showallanswers}{\par\unvbox\allanswers} % 结束 Phil 的回答

% 有没有更好的办法? \newcommand*{\getanswer}5{% \ifthenelse{\equal{#5}{a}} {\begin{answer}\thequestion. (a)~#1\end{answer}} {\ifthenelse{\equal{#5}{b}} {\begin{answer}\thequestion. (b)~#2\end{answer}} {\ifthenelse{\equal{#5}{c}} {\begin{answer}\thequestion. (c)~#3\end{answer}} {\ifthenelse{\equal{#5}{d}} {\begin{answer}\thequestion. (d)~#4\end{answer}} {\begin{answer}\textbf{\thequestion. (#5)~答案选项无效。}\end{answer}}}}} }

\setlength\parindent{0pt} %使用 \choice{ }{ }{ }{ } %(A B C D) \newcommand{\fourch}5{ \par \begin{tabular}{*{4}{@{}p{0.23\textwidth}}} (a)~#1 & (b)~#2 & (c)~#3 & (d)~#4 \end{表格} \getanswer{#1}{#2}{#3}{#4}{#5} }

%(A)(B) %(光盘) \newcommand{\twoch}5{ \par \开始{表格}{{2}{@{}p{0.46\textwidth}}} (a)~#1 和 (b)~#2 \end{表格} \par \开始{表格}{{2}{@{}p{0.46\textwidth}}} (c)〜#3&(d)〜#4 \end{表格} \getanswer{#1}{#2}{#3}{#4}{#5} }

%(A) %(乙) %(C) %(四) \newcommand{\onech}5{ \par (a)~#1 \par (b)~#2 \par (c)~#3 \par (d)~#4 \getanswer{#1}{#2}{#3}{#4}{#5} }

\新长度\宽度cha \新长度\宽度chb \新长度\宽度chc \新长度\宽度chd \新长度\宽度 \新长度\tab最大宽度

\setlength\tabmaxwidth{0.96\textwidth} \新长度\第四个标签宽度 \setlength\fourthtabwidth{0.25\textwidth} \新长度\半宽度 \setlength\halftabwidth{0.5\textwidth}

\newcommand{\choice}5{% \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%

% 这些 if 语句绕过了 \onech 选项。 % \ifdim\widthch<\fourthtabwidth % \fourch{#1}{#2}{#3}{#4}{#5} % \else\ifdim\widthch<\halftabwidth % \ifdim\widthch>\fourthtabwidth % \twoch{#1}{#2}{#3}{#4}{#5} % \别的 % \onech{#1}{#2}{#3}{#4}{#5} % \fi\fi\fi}

% 允许使用 \onech 选项。 \ifdim\widthch>\halftabwidth \onech{#1}{#2}{#3}{#4}{#5} \else\ifdim\widthch<\halftabwidth \ifdim\widthch>\fourthtabwidth \twoch{#1}{#2}{#3}{#4}{#5} \别的 \fourch{#1}{#2}{#3}{#4}{#5} \fi\fi\fi}

\开始{文档}

\大的

\noindent{\bf Ma 12 长测试 1\hfill 2017 年 2 月 9 日}

\medskip\hrule

\begin{questions} \question Um capacitor $C$ é submetido a uma tensão $V$. A energia armazenada no capacitor é igual a: \choice{$CV^2$}{$0.5CV^2$}{$2CV^2$}{$CV$}{b} \question Uma tensão V é aplicada a um circuito RL em série. A corrente em regime permanente é igual a: \choice{$V/R$}{$V/L$}{$\dfrac{V}{\sqrt{R^2+L^2}}$}{zero}{a} \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}{a} \question The value of $i + i^{22} + i^{23} + i^{24} + i^{25}$ is \choice{i}{-i}{1}{-1}{c} \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$}{a} \question To complete the song, the last answer should be \choice{a}{b}{c}{d}{e} % Invalid answer choice \question To complete the song, the last answer should be \choice{a long tex a long tex a long tex a long tex a long tex a long tex a long tex a long tex a long tex}{b}{c}{d}{a} \end{questions} %\newpage %Uncomment to put on new age \bigskip Answer Key: \bigskip \showallanswers % Phil Hirschorn \end{document}

在此处输入图片描述

答案1

正如评论所说,您似乎想要做两件事:创建一个两列环境,然后在答案部分添加水平线。

要创建两个(或更多列),您可以使用包multicol。一种可能的使用方式是:

% more preamble
\usepackage{multicol}

\begin{document}

\begin{multicols}{3}  % the number here is the number of columns
[  % the part between square brackets isn't divided into columns
\section{First Section}
All human things are subject to decay. And when fate summons, Monarchs must 
obey.
]  % now the columns start
Hello, here is some text without a meaning.  This text should show what 
a printed text will look like at this place.
If you read this text, you will get no information.  Really?  Is there 
no information?  Is there...
\end{multicols}

% rest of the document

使用带有包选项的先前代码exam,您可以使用您的代码创建多个列。

要创建不带部分名称数字的水平规则,可以使用以下代码:

\section*{Answer to Practice Exercises}
\hline

\rule或者,如果您遇到行距问题,可以使用:

\section*{Answer to Practice Exercises}
\rule{\textwidth}{0.4pt}

最后一部分应该在里面\showallanswers(顺便说一下,这是来自包的命令exam?)

相关内容