我正在输入问题集的解决方案。我定义了一个theorem
和solution
环境,如以下文档所示。
\documentclass{article}
\usepackage{amsthm}
\theoremstyle{plain}
\newtheorem{theorem}{Theorem}
\theoremstyle{definition}
\newtheorem{problem}{Problem}
\theoremstyle{remark}
\newtheorem*{solution}{Solution}
\begin{document}
\begin{theorem}
The word ``theorem'' at the beginning of a theorem is bold, unless it appears inside a solution.
\end{theorem}
\begin{problem}
What is $2+2$?
\end{problem}
\begin{solution}
We use the following theorem.
\begin{theorem} Numbers can be added.\end{theorem}
The result is therefore $2+2=4$.
\end{solution}
\end{document}
对于定理外部解决方案中,“定理”一词正确显示为粗体。然而,里面解决方案环境,定理环境的标题为斜体,与解决方案环境的风格相匹配。
我如何才能使解决方案中的定理正确地以粗体显示?
答案1
这是 的一个缺点amsthm
。您可以使用以下方法解决此问题thmtools
:
\documentclass{article}
\usepackage{amsthm,thmtools}
\declaretheoremstyle[
headfont=\bfseries,
bodyfont=\itshape,
]{myplain}
\declaretheoremstyle[
headfont=\bfseries,
bodyfont=\normalfont,
]{mydefinition}
\declaretheoremstyle[
headfont=\itshape,
bodyfont=\normalfont,
]{myremark}
\declaretheorem[
style=myplain,
name=Theorem,
]{theorem}
\declaretheorem[
style=mydefinition,
name=Problem,
]{problem}
\declaretheorem[
style=myremark,
unnumbered,
name=Solution,
]{solution}
\begin{document}
\begin{theorem}
The word ``theorem'' at the beginning of a theorem is bold, unless it appears inside a solution.
\end{theorem}
\begin{problem}
What is $2+2$?
\end{problem}
\begin{solution}
We use the following theorem.
\begin{theorem} Numbers can be added.\end{theorem}
\begin{problem} Numbers can be added.\end{problem}
The result is therefore $2+2=4$.
\end{solution}
\end{document}