有没有办法根据是否打印解决方案来设置标题内容?
\documentclass[headsepline]{scrartcl}
\usepackage{xsim}
\usepackage{scrlayer-scrpage}
\cohead{Solutions are not printed}
%\xsimsetup{solution/print}
%\cohead{Solutions are printed}
\begin{document}
\begin{exercise}
body of exercise \theexercise
\end{exercise}
\begin{solution}
solution of the exercise number \theexercise
\end{solution}
\begin{exercise}
body of exercise \theexercise
\end{exercise}
\begin{solution}
solution of the exercise number \theexercise
\end{solution}
\begin{exercise}
body of exercise \theexercise
\end{exercise}
\begin{solution}
solution of the exercise number \theexercise
\end{solution}
\end{document}
答案1
您可以设置一个新\if
标志\ifprintsolutions
(默认false
)。通过声明\printsolutionstrue
,标题会随着要打印的解决方案而改变。
\newif\ifprintsolutions
\printsolutionstrue% COMMENT THIS LINE OR NOT
\documentclass[headsepline]{scrartcl}
\usepackage{xsim}
\usepackage{scrlayer-scrpage}
\ifprintsolutions
\xsimsetup{solution/print}
\cohead{Solutions are printed}
\else
\cohead{Solutions are not printed}
\fi
\begin{document}
\begin{exercise}
body of exercise \theexercise
\end{exercise}
\begin{solution}
solution of the exercise number \theexercise
\end{solution}
\begin{exercise}
body of exercise \theexercise
\end{exercise}
\begin{solution}
solution of the exercise number \theexercise
\end{solution}
\begin{exercise}
body of exercise \theexercise
\end{exercise}
\begin{solution}
solution of the exercise number \theexercise
\end{solution}
\end{document}