我正在做多项选择题试卷,我想知道任务环境中是否有类似于 \correctchoice 的东西?我的目标是当我使用\打印答案,每道题的正确选项都以粗体红色高亮显示。如何实现?
\documentclass[a4peper,12pt,addpoints]{exam}
\date{}
\pagestyle{empty}
\usepackage[top=0.6in, bottom=1in, left=0.6in, right=0.55in]{geometry}
\usepackage{fancybox}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{tasks}
\usepackage{mathpazo}
\usepackage[utf8]{inputenc}
\usepackage[onehalfspacing]{setspace}
\usepackage{anyfontsize}
\usepackage{graphicx}
\usepackage{amsfonts}
\usepackage[ddmmyyyy]{datetime}
\usepackage{multicol,adjustbox}
\usepackage{cellspace}
\usepackage{gensymb}
\usepackage{color, colortbl}
\title{\vspace{-1.6cm}\bfseries\huge \fbox{\fbox{DAILY PRACTICE PROBLEM}} \\[3mm]
\Large \fbox{XYZ}\\[5mm] \hline\hline \vspace{0.3 cm}
\normalsize MM: 50 \hfill Duration : 30 minutes \hfill DPP 1 \vspace{0.3 cm} \hline \hline
}
\settasks{label=(\Alph*), label-width=2em}
\renewcommand{\solutiontitle}{\noindent\textbf{Answer:}\enspace}
\SolutionEmphasis{\color{red}}
%\printanswers
\begin{document}
\maketitle
\vspace{-2.8 cm}
\begin{center}
\subsection*{\Large{IMPORTANT INSTRUCTIONS}}
\end{center}
\rule[2ex]{\textwidth}{2pt}
\begin{enumerate}\singlespacing \small
\item Section A contains TEN objective type question having only one option correct. Each question carries $4$ marks.
\item Section B contains FIVE True/False questions. Each question carries $2$ marks.
\item In section A, $4$ marks will be awarded for marking correct answer, $-1$ for marking incorrect answer and $0$ marks for not marking the answer.
\item There is no negative marking in section B .
\end{enumerate}
\rule[2ex]{\textwidth}{1.5pt}
{ \fontsize{12}{14.4}\selectfont
\begin{center}
\cellwidth{0.3cm}
\hqword{\textbf{Question:}}
\hpword{\textbf{Marks Allotted:}}
\hsword{\textbf{Marks Obtained:}}
\gradetable[h][questions]
\end{center}
\rule[2ex]{\textwidth}{1.5pt}
}
\vspace{-1.5 cm}
\begin{center}
\section*{\ovalbox{\Large{SECTION A}}}
\end{center}
\fontsize{15}{18}\selectfont
\begin{questions}
\pointformat{}
\question[4] The set of intelligent students in a class is :
\begin{tasks}(2)
\task A null set
\task A singleton set
\task A finite set
\task Not a well defined collection
\end{tasks}
\thispagestyle{empty}
\question[4] If $n(U)=700$, $n(A)=200$, $n(B)=300$ and $n(A \cap B)=100$, then value of $n(A^c \cap B^c)$ is :
\begin{tasks}(2)
\task $400$
\task $600$
\task $300$
\task $200$
\end{tasks}
\end{questions}
\end{document}
答案1
您的\maketitle
输入似乎有错误,所以我将其注释掉。至于手头的问题,我定义
\newcommand\correct[1]{#1}
\let\svprintanswers\printanswers
\renewcommand\printanswers{\def\correct{\textcolor{red}}\svprintanswers}
然后,对于正确的答案,我使用语法\correct{<correct answer>}
,如
\begin{tasks}(2)
\task \correct{A null set}
\task A singleton set
\task A finite set
\task Not a well defined collection
\end{tasks}
然后,当\printanswers
处于活动状态时,将以红色打印。否则,将以当前颜色打印。
\documentclass[a4peper,12pt,addpoints]{exam}
\date{}
\pagestyle{empty}
\usepackage[top=0.6in, bottom=1in, left=0.6in, right=0.55in]{geometry}
\usepackage{fancybox}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{tasks}
\usepackage{mathpazo}
\usepackage[utf8]{inputenc}
\usepackage[onehalfspacing]{setspace}
\usepackage{anyfontsize}
\usepackage{graphicx}
\usepackage{amsfonts}
\usepackage[ddmmyyyy]{datetime}
\usepackage{multicol,adjustbox}
\usepackage{cellspace}
\usepackage{gensymb}
\usepackage{color, colortbl}
\title{\vspace{-1.6cm}\bfseries\huge \fbox{\fbox{DAILY PRACTICE PROBLEM}} \\[3mm]
\Large \fbox{XYZ}\\[5mm] \hline\hline \vspace{0.3 cm}
\normalsize MM: 50 \hfill Duration : 30 minutes \hfill DPP 1 \vspace{0.3 cm} \hline \hline
}
\settasks{label=(\Alph*), label-width=2em}
\renewcommand{\solutiontitle}{\noindent\textbf{Answer:}\enspace}
\SolutionEmphasis{\color{red}}
\newcommand\correct[1]{#1}
\let\svprintanswers\printanswers
\renewcommand\printanswers{\def\correct{\textcolor{red}}\svprintanswers}
\printanswers
\begin{document}
%\maketitle% HAS ERRORS IN INPUT
\vspace{-2.8 cm}
\begin{center}
\subsection*{\Large{IMPORTANT INSTRUCTIONS}}
\end{center}
\rule[2ex]{\textwidth}{2pt}
\begin{enumerate}\singlespacing \small
\item Section A contains TEN objective type question having only one option correct. Each question carries $4$ marks.
\item Section B contains FIVE True/False questions. Each question carries $2$ marks.
\item In section A, $4$ marks will be awarded for marking correct answer, $-1$ for marking incorrect answer and $0$ marks for not marking the answer.
\item There is no negative marking in section B .
\end{enumerate}
\rule[2ex]{\textwidth}{1.5pt}
{ \fontsize{12}{14.4}\selectfont
\begin{center}
\cellwidth{0.3cm}
\hqword{\textbf{Question:}}
\hpword{\textbf{Marks Allotted:}}
\hsword{\textbf{Marks Obtained:}}
\gradetable[h][questions]
\end{center}
\rule[2ex]{\textwidth}{1.5pt}
}
\vspace{-1.5 cm}
\begin{center}
\section*{\ovalbox{\Large{SECTION A}}}
\end{center}
\fontsize{15}{18}\selectfont
\begin{questions}
\pointformat{}
\question[4] The set of intelligent students in a class is :
\begin{tasks}(2)
\task \correct{A null set}
\task A singleton set
\task A finite set
\task Not a well defined collection
\end{tasks}
\thispagestyle{empty}
\question[4] If $n(U)=700$, $n(A)=200$, $n(B)=300$ and $n(A \cap B)=100$, then value of $n(A^c \cap B^c)$ is :
\begin{tasks}(2)
\task $400$
\task $600$
\task \correct{$300$}
\task $200$
\end{tasks}
\end{questions}
\end{document}
如果如所示,你还想将其加粗,那么\renewcommand
可以定义为
\renewcommand\printanswers{%
\def\correct##1{\textcolor{red}{\bfseries##1}}%
\svprintanswers}
但是,数学模式下的答案(例如问题 2)不会以粗体显示。