考试类别:相同空间解与无解

考试类别:相同空间解与无解

在考试课上,通过为学生插入与答案行大小相同的固定小页面,您可以在打印答案和不打印答案时创建相同的空间。为什么深度仍然不同?不要告诉我使用 \vspace。在此处输入图片描述

\documentclass[11pt,a4paper,addpoints]{exam}
\unframedsolutions

\usepackage{tikz}
\usepackage{graphicx}
\usepackage{geometry}
\usepackage{calc}
\usepackage[skins]{tcolorbox}
\usepackage{calc}
\newgeometry{left=2cm,top=2cm,right=2cm,bottom=2cm}

\newtcolorbox{greenbox}[1][]{%
  size=fbox,
  arc=5mm,
  boxsep=0.7cm,
  colframe=green,
  colback=green!8,
  beforeafter skip=5mm,% <--- Space setting before and after
  #1%
}

%\printanswers
\begin{document}

\begin{questions}


\begin{greenbox}
  \question[2] What is the first question?
  \begin{solutionorlines}[4cm]               %heidht no answers=4cm
  \begin{minipage}[t][4cm]{\textwidth-1.4cm} %height answers =4cm
   The depth of this box is larger when answers are printed compared to answers not printed. How do I make "answers" and "no answers" the same dimension?
   \end{minipage}
  \end{solutionorlines}
\end{greenbox}%


\end{questions}

\end{document}

答案1

我认为exam课程本身应该为这个问题提供解决方案,但我对它不够熟悉,不知道这是否是一个配置问题。

为了解决这个问题,你可以将解决方案部分嵌入另一个minipage。以下代码始终对答案和行使用相同大小的空间:

\documentclass[11pt,a4paper,addpoints]{exam}
\unframedsolutions

\usepackage{tikz}
\usepackage{graphicx}
\usepackage{geometry}
\usepackage{calc}
\usepackage[skins]{tcolorbox}
\usepackage{calc}
\newgeometry{left=2cm,top=2cm,right=2cm,bottom=2cm}

\newtcolorbox{greenbox}[1][]{%
  size=fbox,
  arc=5mm,
  boxsep=0.7cm,
  colframe=green,
  colback=green!8,
  beforeafter skip=5mm,% <--- Space setting before and after
  #1%
}

%\printanswers
\begin{document}

\begin{questions}


\begin{greenbox}
  \question[2] What is the first question?
  \par\begin{minipage}[t][4cm]{\linewidth} %height answers =4cm
    \begin{solutionorlines}[4cm]               %heidht no answers=4cm
    \begin{minipage}[t][4cm]{\linewidth-1.9cm} %height answers =4cm
     The depth of this box is larger when answers are printed compared to answers not printed. How do I make "answers" and "no answers" the same dimension?
    \end{minipage}%
    \end{solutionorlines}
  \end{minipage}
\end{greenbox}%


\end{questions}

\end{document}

相关内容