使用 exsheets 包时,我遇到了 \printsolution[all] 的问题。
\documentclass[UTF8,11pt,a4paper]{book}
\usepackage{kantlipsum}
\usepackage[load-tasks=true]{exsheets}
\DeclareInstance{exsheets-heading}{exclist}{default}{
runin = true ,
number-post-code = \space ,
attach = { main[r,vc]number[l,vc](-3em,0pt) } ,
above = 0pt,
below = 0pt
}
\SetupExSheets{
% solution/print = true ,
headings = exclist ,
headings-format = \bfseries,
% counter-format = ch.qu ,
counter-within = chapter
}
\usepackage{scrextend}% needed with a KOMA-Script class, `addmargin' environment
\usepackage{etoolbox}
\AtBeginEnvironment{question}{\addmargin[3em]{0em}}
\AtEndEnvironment{question}{\endaddmargin}
\AtBeginEnvironment{solution}{\addmargin[3em]{0em}}
\AtEndEnvironment{solution}{\endaddmargin}
\begin{document}
\chapter{One}
\section{Sec.\thesection }
This is normal text.
\section*{Using solution environment in section }
\begin{question}
This is sample question 1.
\end{question}
\begin{solution}
This is sample solution 1.
\end{solution}
\begin{question}
This is sample question 2.
\end{question}
\begin{solution}
This is sample solution 2.
\end{solution}
This is normal text. This is normal text. This is normal text. This is normal text. This is normal text.
\section*{Using printsolutions at the end}
\printsolutions
This is normal text. This is normal text. This is normal text. This is normal text. This is normal text.
\end{document}
输出:
exsheet 包在本节中运行良好,但在书末使用 \printsolutions 时,答案超出了页边距。我不知道如何纠正它,有人能帮助我吗?谢谢!
答案1
由于解决方案环境未被使用,因此\printsolutions
\AtBeginEnvironment{solution}{...}
对在那里打印的解决方案没有影响。
解决方案:使用pre-hook
和post-hook
选项来提出问题和解决方案:
\SetupExSheets{
question/pre-hook = \addmargin[3em]{0em} ,
question/post-hook = \endaddmargin ,
solution/pre-hook = \addmargin[3em]{0em} ,
solution/post-hook = \endaddmargin
}
solution
如果通过通过 环境,则在打印的每个解决方案之前和之后将使用相应的代码\printsolution
。
完整示例:
\documentclass[11pt,a4paper]{book}
\usepackage{kantlipsum}
\usepackage{exsheets}
\DeclareInstance{exsheets-heading}{exclist}{default}{
runin = true ,
number-post-code = \space ,
attach = { main[r,vc]number[l,vc](-3em,0pt) } ,
above = 0pt,
below = 0pt
}
\SetupExSheets{
% solution/print = true ,
headings = exclist ,
headings-format = \bfseries,
counter-within = chapter
}
\usepackage{scrextend}% needed with a KOMA-Script class, `addmargin' environment
\SetupExSheets{
question/pre-hook = \addmargin[3em]{0em} ,
question/post-hook = \endaddmargin ,
solution/pre-hook = \addmargin[3em]{0em} ,
solution/post-hook = \endaddmargin
}
\begin{document}
\section{Sec.\thesection}
This is normal text.
\section*{Using solution environment in section}
\begin{question}
This is sample question 1.
\end{question}
\begin{solution}
This is sample solution 1.
\end{solution}
\begin{question}
This is sample question 2.
\end{question}
\begin{solution}
This is sample solution 2.
\end{solution}
This is normal text. This is normal text. This is normal text. This is normal
text. This is normal text.
\section*{Using printsolutions at the end}
\printsolutions
This is normal text. This is normal text. This is normal text. This is normal
text. This is normal text.
\end{document}