xsim解決方案環境列印後的註釋

xsim解決方案環境列印後的註釋

solution如果我在包的環境之後添加註釋,xsim則註釋將在解決方案之前列印。

在此輸入影像描述

\documentclass[]{article}
  \usepackage{xsim}

\begin{document}
   \begin{exercise} % execice 1
      Statement of exercise 1 
   \end{exercise}
   \begin{solution}[print] % I need a comment here
      Solution of exercise 1 
   \end{solution}
\end{document}

答案1

此行為不是錯誤。這是逐字讀取內容然後寫入外部文件的副作用。

實際上,手冊中提到了這一點(第 5 節關於運動環境如何運作):

另一件需要記住的事情是:環境在許多方面與filecontents環境的運作方式相同。這也意味著您不能對環境的第一行進行註釋:

\begin{exercise}[points=2] % this comment will cause trouble
  Lorem ipsum
\end{exercise}

只要把你的評論放在下面一行就可以了:

\documentclass[]{article}
\usepackage{xsim}

\begin{document}

\begin{exercise}
  % execice 1
  Statement of exercise 1 
\end{exercise}
\begin{solution}[print]
  % I need a comment here
  Solution of exercise 1 
\end{solution}

\end{document}

相關內容