答案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}