試験クラス: 同じ空間のソリューションとソリューションなし

試験クラス: 同じ空間のソリューションとソリューションなし

試験クラスでは、学生用の解答行と同じサイズの固定ミニページを挿入することで、解答が印刷されるときも印刷されないときも同じスペースが作成されます。なぜ深さがまだ異なるのでしょうか? \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}

関連情報