在考试课上有一个选项\printanswer
。我对此没有问题,但是当我使用表格时,我无法将答案放入单元格中。
\documentclass[11pt,a4paper,addpoints,twoside]{exam}
\noprintanswers
\printanswers
\setlength\answerclearance{1ex}
\renewcommand{\solutiontitle}{\textbf{Oplossing:}\par}
\pointpoints{punt}{punten}
\pointsinrightmargin
\boxedpoints
%\noboxedpoints
\begin{document}
\begin{questions}
\question[6] Vul aan met de juiste waarde
\renewcommand{\arraystretch}{2} %verhoogt de rijhoogte
\begin{center}
\begin{tabular}{|c| c| p{3cm}| p{3cm} | p{3cm}|}
\hline
a&b&7b&a+b&2a+b\\
\hline
\hline
5&2&&&\\
\hline
1&4&&&\\
\hline
\end{tabular}
\end{center}
\end{questions}
\end{document}
答案1
如果您切换行,此最小工作示例将起作用\noprintanswers
。框产生的增加的垂直间距可能可以自定义。请参阅http://www-math.mit.edu/~psh/exam/examdoc.pdf以获得关于该主题的进一步帮助。
\documentclass[%
,answers % switches on the use of solutions in general
,11pt
,a4paper
,addpoints
,twoside
]{exam}
\usepackage{booktabs}
%\noprintanswers % toggle this for answers or no answers!
\pointsinrightmargin
\boxedpoints
%\noboxedpoints
\begin{document}
\begin{questions}
\question[6] Vul aan met de juiste waarde
\renewcommand{\arraystretch}{2} %verhoogt de rijhoogte
\begin{center}
\begin{tabular}{c c | p{3cm} p{3cm} p{3cm}}
\toprule
$a$&$b$&$7b$&$a+b$&$2a+b$\\
\midrule
5&2&\begin{solution}$14$\end{solution}&\begin{solution}$7$\end{solution}&\begin{solution}$12$\end{solution}\\
1&4&\begin{solution}$28$\end{solution}&\begin{solution}$5$\end{solution}&\begin{solution}$6$\end{solution}\\
\bottomrule
\end{tabular}
\end{center}
\end{questions}
\end{document}
更新
正如 OP 在评论中提到的那样,搜索了带有答案行的解决方案。 它们按预期工作,如以下代码片段所示:
\question[6] Vul aan met de juiste waarde
\renewcommand{\arraystretch}{2} %verhoogt de rijhoogte
\begin{center}
\begin{tabular}{c c | p{3cm} p{3cm} p{3cm}}
\toprule
$a$&$b$&$7b$&$a+b$&$2a+b$\\
\midrule
5&2&\answerline&\answerline&\answerline\\
1&4&\answerline&\answerline&\answerline\\
\bottomrule
\end{tabular}
\end{center}
答案2
我创建了一个新命令 \solutiontable{},其:
- 无论是否打印解决方案,都会给出相同的单元格大小(它不会“摆动”)
- 可以通过 examclass 的命令进行阴影化:\shadedsolutions
- 可以通过 examclass 的命令来着色:\SolutionEmphasis{\color{color}}
- 不使用 \framedsolutions(不知道如何在不改变解决方案大小的情况下做到这一点)
引用
\documentclass[11pt,a4paper]{exam}
\usepackage[latin1]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{xcolor,colortbl}
\printanswers %toggle this on or of for solutions or not
\SolutionEmphasis{\color{red}} %color font solutions
\unframedsolutions %Not necessary for table environment
\shadedsolutions %gives backgroundcolor to solutions
\begin{document}
\makeatletter%
\newcommand{\solutiontable}[1]{\ifprintanswers\begingroup\Solution@Emphasis#1\if@shadedsolutions%
{\cellcolor{SolutionColor}}%
\else%
\fi\endgroup\else\phantom{#1}\fi}%
\makeatother%
\begin{questions}
\question[1] Fill in the missing cell of this table:\par
\begin{tabular}{|l|l|c|c|}
\hline Mechanics &Equation &Unit\\
\hline Distance &\solutiontable{$x=x_{0}+v_{0}t+\dfrac{1}{2}at^{2}$} &m\\
\hline Weight &$w=m\cdot g $ &kg\\
\hline Kinetic energy&$K=\dfrac{1}{2}mv^{2}$ &J\\
\hline%
\end{tabular}%
\end{questions}
\end{document}
引用