將解決方案放在 T/F 選擇旁邊

將解決方案放在 T/F 選擇旁邊

設定

我有以下 MWE:

  \documentclass[addpoints,12pt]{exam}

  \usepackage{color}
  \usepackage{amsmath}
  \usepackage{amssymb}

  \checkboxchar{$\Box$}
  \checkedchar{$\blacksquare$}

  \bracketedpoints
  \shadedsolutions
  \renewcommand{\solutiontitle}{\noindent\textbf{Solution:}\par\noindent}


  \begin{document}

  \textbf{\textsc{True/False:}  [1pt each]}
  \vspace{0.1in}
   \begin{questions}

   \question Every normal distribution has a bell-shaped graph.

   \begin{oneparcheckboxes}
   \correctchoice T
   \choice F
   \end{oneparcheckboxes}

   \question If $X$ is a binomial random variable, then $X$ is approx. normal.

  \begin{oneparcheckboxes}
  \choice T
  \correctchoice F
  \end{oneparcheckboxes}

  \question Why did the chicken cross the road?
  \begin{solution}[1.0in]
  To get to the other side!
  \end{solution}

  \end{questions}
  \end{document}

這會產生完美的(簡短的)考試。現在,如果我添加answers選項 - 即,將第一行更改為\documentclass[addpoints,12pt,answers]{exam}- 那麼我將得到正確的 T/F 選擇,以及簡答題的解決方案。

問題

我還想做的是在每個 T/F 問題旁邊添加一個簡短的單行解決方案,並進行一些推理。該解決方案將:

  • 有陰影背景
  • 與 T 和 F 選擇在同一行
  • answers僅在給出選項時出現

是否有捷徑可尋?

答案1

我創建了\explanation, 添加到 T/F 環境的末尾oneparcheckboxes

  \documentclass[addpoints,12pt,answers]{exam}

  \usepackage{color}
  \usepackage{amsmath}
  \usepackage{amssymb}

  \checkboxchar{$\Box$}
  \checkedchar{$\blacksquare$}

  \bracketedpoints
  \shadedsolutions
  \renewcommand{\solutiontitle}{\noindent\textbf{Solution:}\par\noindent}
  \definecolor{SolutionColor}{gray}{0.8}
  \def\explanation#1{%
    \ifprintanswers\mdseries\colorbox{SolutionColor}{\strut #1}\fi}

  \begin{document}

  \textbf{\textsc{True/False:}  [1pt each]}
  \vspace{0.1in}
   \begin{questions}

   \question Every normal distribution has a bell-shaped graph.

   \begin{oneparcheckboxes}
   \correctchoice T 
   \choice F
   \explanation{Explanation goes here}
   \end{oneparcheckboxes}

   \question If $X$ is a binomial random variable, then $X$ is approx. normal.

  \begin{oneparcheckboxes}
  \choice T
  \correctchoice F
   \explanation{Another explanation goes here}
  \end{oneparcheckboxes}

  \question Why did the chicken cross the road?
  \begin{solution}[1.0in]
  To get to the other side!
  \end{solution}

  \end{questions}
  \end{document}

在此輸入影像描述

相關內容