exsheets宏包的使用

2020-02-14 17:29发布

用exsheets宏包实现例1,练习1,例2,练习2,例3,练习3 的效果,谢谢! 例题与练习使用 question 环境时,虽然 name 不同,但计数器依然读数,知道如何处理。 https://...

用exsheets宏包实现例1,练习1,例2,练习2,例3,练习3 的效果,谢谢! 例题与练习使用 question 环境时,虽然 name 不同,但计数器依然读数,知道如何处理。 https://paste.ubuntu.com/p/7Hb5smQSCS/
该问题目前已经被作者或者管理员关闭, 无法添加新回复
2条回答
论坛 github.com/C
2020-02-14 18:22 .采纳回答
**提醒** exsheets 宏包作者[回复](https://tex.stackexchange.com/questions/249605/exsheets-counters-for-new-question-pairs/528436?noredirect=1#comment1336434_528436): > `exsheets` is not developed any more. But its successor package `xsim` supports it from the beginning in early 2017. 1. `exsheets` 宏包尚不支持多个计数器功能。 1. 使用 `pre-hook` 和 `post-hook` 可以模拟多个计数器的功能。 1. 如果不需要用到分值等功能,可以用 `xsim` 宏包,它是支持的。 尝试一:使用 `pre-hook` 和 `post-hook` 模拟多个计数器: ```tex \documentclass{ctexart} \usepackage{exsheets} \newcounter{exercise} \newcounter{temp} % set counter #1 to #2 \newcommand\replaceCounter[2]{% \setcounter{temp}{\value{#1}}% \setcounter{#1}{\value{#2}}% } % restore counter #1 to #2, and from temp, \newcommand\restoreCounter[2]{% \setcounter{#2}{\value{#1}}% \setcounter{#1}{\value{temp}}% } \NewQuSolPair {exercise}[name=练习, post-hook=\restoreCounter{question}{exercise}] {exsolution}[name=解答~练习, print=true] \RenewQuSolPair {question}[name=例, post-hook=\replaceCounter{question}{exercise}] {solution}[name=解答~例, print=true] \begin{document} \begin{question} q1 \end{question} \begin{solution} q1 \end{solution} \begin{exercise} ex1 \end{exercise} \begin{question} q2 \end{question} \begin{exercise} ex2 \end{exercise} \begin{exsolution} ex2 \end{exsolution} \end{document} ``` 尝试二:`pre-hook` 的位置不够前,为此增加选项 `pre-counter-hook` ```tex \documentclass{ctexart} \usepackage{exsheets} \usepackage{xpatch} \ExplSyntaxOn \tl_new:N \l__exsheets_questions_pre_counter_hook_tl \keys_define:nn { exsheets / question } { pre-counter-hook .tl_set:N = \l__exsheets_questions_pre_counter_hook_tl } \xpatchcmd \__exsheets_start_question_if_used:n { \refstepcounter{question} } { \l__exsheets_questions_pre_counter_hook_tl \refstepcounter{question} } {}{\fail} \ExplSyntaxOff \makeatletter \def\default@counter{question} % use \default@counter as counter #1 \newcommand\useCounter[1]{% \setcounter{@\default@counter}{\value{\default@counter}}% \setcounter{\default@counter}{\value{#1}}% } % restore value of \default@counter \newcommand\restoreCounter[1]{% \setcounter{#1}{\value{\default@counter}}% \setcounter{\default@counter}{\value{@\default@counter}}% } \makeatother \newcounter{exercise} \newcounter{@question} \NewQuSolPair {exercise}[ name=练习, pre-counter-hook=\useCounter{exercise}, post-hook=\restoreCounter{exercise}] {exsolution}[name=解答~练习, print=true] \RenewQuSolPair {question}[name=例] {solution}[name=解答~例, print=true] \begin{document} 同上,略 \end{document} ``` ![](https://pics.latexstudio.net/data/images/202002/2a5b90e177e345f.png)

一周热门 更多>