考试包:仅为 \titledquestion 添加标题

考试包:仅为 \titledquestion 添加标题

我想使用该exam包,并提出以下格式的标题和非标题问题:

\question Which sentence is true?

应该给予


**Question 1:**                  [1] (<-- in a box on the right margin)  
Which sentence is true?

但以下

\titledquestion{Resolution}
\begin{parts}
\part[1] What is up?
\part[1] What is going on?
\end{parts}

应该给予


**Question 2:** Resolution [6 points total] <-- next to resolution

(a) What is up?                                  [3](@box right margin)
(b) What is going on?                            [3](@box right margin)

这是我的最小可工作示例,但我遇到的问题是的格式question和的格式titledquestion是相同的,因此我想分别格式化标题,并且理想情况下将无标题问题的点也作为右边距的框。


\documentclass[addpoints,12pt]{exam}
\usepackage{amssymb}

% to have the points on the right margin
\pointsinrightmargin

% make boxes/brackets around the points instead of parantheses
\boxedpoints

%%%%%%% format the question header

\qformat{
 \textbf{Question \thequestion:}
 \textit{\thequestiontitle}
 [\totalpoints~\points]\hfill
 \vrule depth 0.75em width 0pt
}

% get rid of extra indentation after the start of a question

\renewcommand{\questionshook}{%
 \setlength{\leftmargin}{0 pt}%
 \setlength{\labelwidth}{-\labelsep}%
}

%%%%%% change the check-box symbols

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


\begin{questions}

\question[1] Which of these is true
\begin{checkboxes} 
\choice 1=1
\choice 2=1
\choice 3=1
\end{checkboxes} 

\titledquestion{Resolution}
Here's the intro ...
\begin{parts}
\part[3] What's up?
\part[3] What's going on?
\end{parts}

\end{questions}

\end{document}

答案1

如果问题没有标题,则考试类会将标题设置为当前问题标签。以下代码测试标题是否为当前标签,并且仅在标题与标签不同时才打印标题:

\documentclass[addpoints,12pt]{exam}
\usepackage{amssymb}

% to have the points on the right margin
\pointsinrightmargin

% make boxes/brackets around the points instead of parantheses
\boxedpoints

%%%%%%% format the question header
\makeatletter
\qformat{%
 \textbf{Question \thequestion:}%
 \if\thequestiontitle\csname p@question\endcsname
                           \csname thequestion\endcsname
 \else%
 \textit{\space\thequestiontitle}
 \fi%
 \hfill%[\totalpoints~\points]
\rlap{%
%\hskip-\@totalleftmargin
%                  \hskip\textwidth
                  \hskip\@rightmargin
                  \hskip-\rightpointsmargin
                  \llap{\point@block}%
            }%
% \vrule depth 0.75em width 0pt
}
\makeatother
% get rid of extra indentation after the start of a question

\renewcommand{\questionshook}{%
 \setlength{\leftmargin}{0 pt}%
 \setlength{\labelwidth}{-\labelsep}%
}

%%%%%% change the check-box symbols

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


\begin{questions}

\question[1] Which of these is true
\begin{checkboxes} 
\choice 1=1
\choice 2=1
\choice 3=1
\end{checkboxes} 

\titledquestion{Resolution}[5]
Here's the intro ...
\begin{parts}
\part[3] What's up?
\part[3] What's going on?
\end{parts}

\end{questions}

\end{document}

在此处输入图片描述

相关内容