在以下 MWE 中,如何获取有/无包的考试类的问题、部分、子部分和子子部分的交叉引用的所需格式cleveref
?
\documentclass[12pt]{exam}
\usepackage{greekctr,hyperref,cleveref}
\renewcommand\partlabel{(\alph{partno})}
\renewcommand\subpartlabel{(\roman{subpart})}
\renewcommand\subsubpartlabel{(\greek{subsubpart})}
\begin{document}
\begin{questions}
\question The main question. \label{myquestion}
\begin{parts}
\part text \label{mypart}
\begin{subparts}
\subpart text \label{mysubpart}
\begin{subsubparts}
\subsubpart text \label{mysubsubpart}
\end{subsubparts}
\end{subparts}
\end{parts}
\end{questions}
I need to respectively print the cross-references of the\\
question (\verb|\cref{myquestion}|) \cref{myquestion},\\
part (\verb|\cref{mypart}|) \cref{mypart},\\
subpart (\verb|\cref{mysubpart}|) \cref{mysubpart} ,\\
and subsubpart (\verb|\cref{mysubsubpart}|) \cref{mysubsubpart} as\\
``question (1)'', ``part (a)'', ``subpart (i)'', and ``subsubpart ($\alpha$)''.
\end{document}
答案1
cleveref
需要将计数器名称(partno、subpart、subsubpart)与其文本版本结合起来,即partno
→Part number
等。
这种耦合是通过
\crefname{partno}{part number}{part numbers}
其中part number
用于单数引用并且part numbers
是复数形式。
对于大写字母的使用\Crefname{partno}{Part number}{Part numbers}
,\Cref
也可以应用。
请按照您的喜好选择其在文中出现的名称。
\documentclass[12pt]{exam}
\usepackage{greekctr,hyperref,cleveref}
\renewcommand\partlabel{(\alph{partno})}
\renewcommand\subpartlabel{(\roman{subpart})}
\renewcommand\subsubpartlabel{(\greek{subsubpart})}
\crefname{subpart}{sub part}{sub parts}
\crefname{subsubpart}{subsub part}{sub sub parts}
\crefname{partno}{part number}{part numbers}
\crefname{question}{question}{questions}
\creflabelformat{question}{(#2#1#3)}
\begin{document}
\begin{questions}
\question The main question. \label{myquestion}
\begin{parts}
\part text \label{mypart}
\begin{subparts}
\subpart text \label{mysubpart}
\begin{subsubparts}
\subsubpart text \label{mysubsubpart}
\end{subsubparts}
\end{subparts}
\end{parts}
\end{questions}
I need to respectively print the cross-references of the\\
question (\verb|\cref{myquestion}|) \cref{myquestion},\\
part (\verb|\cref{mypart}|) \cref{mypart},\\
subpart (\verb|\cref{mysubpart}|) \cref{mysubpart} ,\\
and subsubpart (\verb|\cref{mysubsubpart}|) \cref{mysubsubpart} as\\
``question (1)'', ``part (a)'', ``subpart (i)'', and ``subsubpart ($\alpha$)''.
\end{document}