![probsoln 在 beamer documentclass 中的解决方案环境](https://linux22.com/image/294945/probsoln%20%E5%9C%A8%20beamer%20documentclass%20%E4%B8%AD%E7%9A%84%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88%E7%8E%AF%E5%A2%83.png)
编译这段代码时
\documentclass{beamer}
%%% save beamer's `solution' environment as `beamersolution':
%\let\beamersolution\solution
%\let\endbeamersolution\endsolution
%%% "delete" the `solution' environment:
%\let\solution\relax
\usepackage{color}
\usepackage{probsoln}
\renewcommand{\solutionname}{Answer}
\begin{defproblem}{prob1}
\begin{onlyproblem}
To be or not to be?
\end{onlyproblem}
\begin{onlysolution}
\begin{solution}
That was the question. This is the answer.
\end{solution}
\end{onlysolution}
\end{defproblem}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\color{red}
\useproblem{prob1}
\showanswers
\useproblem{prob1}
\end{document}
在文章文档类中一切都按应有的方式运行,即:
所有文字为红色,解决方案环境的名称为“Answer”。
不幸的是,beamer 文档类有自己的解决方案环境,并且呈现的代码不会影响 probsoln 提供的解决方案环境。我得到
取消注释注释行有帮助存在 exsheets 包中的问题,但它不适用于 probsoln。我应该怎么做才能让解决方案环境变成红色并更改其名称?
答案1
probsoln
仅solution
在环境尚未定义时才定义环境。如果您确实想使用probsoln
的版本,solution
则需要solution
在加载 之前取消定义环境probsoln
。取消定义环境类似于取消定义命令,但您需要考虑用于结束环境的命令以及启动环境的命令。(通常,如果该命令存在,则\begin{foo}
执行\foo
并\end{foo}
执行\endfoo
。)
\documentclass{beamer}
%%% save beamer's `solution' environment as `beamersolution':
\let\beamersolution\solution
\let\endbeamersolution\endsolution
%%% "delete" the `solution' environment:
\let\solution\relax
\let\endsolution\relax
\usepackage{color}
\usepackage{probsoln}
\renewcommand{\solutionname}{Answer}
\begin{defproblem}{prob1}
\begin{onlyproblem}
To be or not to be?
\end{onlyproblem}
\begin{onlysolution}
\begin{solution}
That was the question. This is the answer.
\end{solution}
\end{onlysolution}
\end{defproblem}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\color{red}
\useproblem{prob1}
\showanswers
\useproblem{prob1}
\end{document}