答案1
编辑
从 0.19 版本 (2015/07/04) 开始,这种 hack 就不再必要了。下面代码的开头部分就足够了:
\documentclass{article}
\usepackage[auto-label]{exsheets}[2015/07/04]
\DeclareInstance{exsheets-heading}{myblock}{default}{
attach = {
main[l,vc]title[l,vc](0pt,0pt) ;
main[r,vc]points[l,vc](\marginparsep,0pt)
} ,
title-post-code = \bfseries\space
to question \GetQuestionProperty{ref}{\CurrentQuestionID}
}
\usepackage{hyperref}
\begin{document}
原始答案
我猜你遇到的问题是,当打印解决方案时,\CurrentQuestionID
它不包含相应的 ID,但实际上会扩展为一个空的标记列表。这可能是缺少的功能,甚至是某种错误,因为可以说\CurrentQuestionID
解决方案也应该有效...
exsheets
以下是未来几天可能会被采纳的建议:
\documentclass{article}
\usepackage[auto-label]{exsheets}
\DeclareInstance{exsheets-heading}{myblock}{default}{
attach = {
main[l,vc]title[l,vc](0pt,0pt) ;
main[r,vc]points[l,vc](\marginparsep,0pt)
} ,
title-post-code = \bfseries\space
to question \GetQuestionProperty{ref}{\CurrentQuestionID}
}
\ExplSyntaxOn
\cs_set_protected:Npn \__exsheets_print_solution:nnnn #1#2#3#4
{
\tl_set:Nn \CurrentQuestionID {#3} % <<< this is needed
\tl_use:N \l__exsheets_solutions_pre_hook_tl
\exsheets_solutions_print_name:nnn {#1} {#2} {#3}
\tl_use:N \l__exsheets_solutions_pre_body_hook_tl
\use:n {#4}
\tl_use:N \l__exsheets_solutions_post_body_hook_tl
\tl_use:N \l__exsheets_solutions_post_hook_tl
\exsheets_h_or_vspace:N \l__exsheets_solutions_skip_below_dim
}
\ExplSyntaxOff
\usepackage{hyperref}
\begin{document}
\section{Problems}
\begin{question}
foo bar baz
\end{question}
\begin{solution}
blah blah
\end{solution}
\begin{question}
foo bar baz
\end{question}
\begin{solution}
blah blah
\end{solution}
\section{Answers}
\SetupExSheets{headings=myblock}
\printsolutions
\end{document}