我使用中提到的代码定理标题:
\begin{theorem}[The title]
Some statement
\end{theorem}
然而,对于amsthm
可选标题——上面:“标题”——既不是大胆的也不斜体,但(普通)罗马。我更喜欢与合作amsthm
,那么我该如何解决这个问题?
更新:应用代码后
\newtheoremstyle{mystyle}% % Name
{}% % Space above
{}% % Space below
{\itshape}% % Body font
{}% % Indent amount
{\bfseries}% % Theorem head font
{.}% % Punctuation after theorem head
{ }% % Space after theorem head, ' ', or \newline
{}% % Theorem head spec (can be left empty, meaning `normal')
\theoremstyle{mystyle}
\newtheorem{theorem}{Theorem}
\begin{document}
\begin{theorem}[abcd]\label{firstlabel}%
111
\end{theorem}
输出如下所示:
括号内的内容仍然不是大胆的。我该如何改变它?
可以通过以下方法解决
\begin{theorem}[\bfseries abcd]\label{firstlabel}%
111
\end{theorem}
尽管我希望将其设置为通用。
答案1
您可以将其放在序言中,而无需定义新的定理样式;事实上,这重新定义了plain
和definition
定理样式,以便定理标题具有与定理标题相同的字体属性:
\usepackage{amsthm}
\makeatletter
\def\th@plain{%
\thm@notefont{}% same as heading font
\itshape % body font
}
\def\th@definition{%
\thm@notefont{}% same as heading font
\normalfont % body font
}
\makeatother
答案2
可以使用 的最后一个参数来解决此问题\newtheoremstyle
。它具有不寻常的格式,即用于打印标题标题的三个参数命令的内容。要获取名称、编号和可选标题,您可以将其设置为
\thmname{#1}\thmnumber{ #2}\thmnote{ (#3)}
这基本上是标准定义
\def\thmhead@plain#1#2#3{%
\thmname{#1}\thmnumber{\@ifnotempty{#1}{ }\@upn{#2}}%
\thmnote{ {\the\thm@notefont(#3)}}}
已删除使用的字体切换命令。
在你的例子中它看起来像
\documentclass{article}
\usepackage{amsthm}
\newtheoremstyle{mystyle}% % Name
{}% % Space above
{}% % Space below
{\itshape}% % Body font
{}% % Indent amount
{\bfseries}% % Theorem head font
{.}% % Punctuation after theorem head
{ }% % Space after theorem head, ' ', or \newline
{\thmname{#1}\thmnumber{ #2}\thmnote{ (#3)}}% % Theorem head spec (can be left empty, meaning `normal')
\theoremstyle{mystyle}
\newtheorem{theorem}{Theorem}
\begin{document}
Some text before.
\begin{theorem}[Our hero]\label{firstlabel}%
The most amazing result you have seen.
\end{theorem}
And some text after.
\end{document}
答案3
这是使用该包的完整 MWE 及其描述amsthm
,有关更多详细信息,请参阅文档第 4.3 节
\documentclass{article}
\usepackage{lipsum}
\usepackage{amsthm}
\newtheoremstyle{mystyle}% % Name
{}% % Space above
{}% % Space below
{\itshape}% % Body font
{}% % Indent amount
{\bfseries}% % Theorem head font
{.}% % Punctuation after theorem head
{ }% % Space after theorem head, ' ', or \newline
{}% % Theorem head spec (can be left empty, meaning `normal')
\theoremstyle{mystyle}
\newtheorem{theorem}{Theorem}
\begin{document}
\begin{theorem}
\lipsum[1]
\end{theorem}
\begin{theorem}
\lipsum[1]
\end{theorem}
\end{document}
答案4
另一种解决方案是使用xpatch
包及其命令来修改包的xpatchcmd
内部命令。通过下面的 MWE 中所示的修改,可选标题始终使用与其余(定理、定义、备注)标题中使用的字体相同的字体。\@thm
amsthm
\documentclass{article}
\usepackage{xpatch,amsthm}
\makeatletter
\xpatchcmd{\@thm}{\fontseries\mddefault\upshape}{}{}{} % same font as thm-header
\makeatother
\newtheorem{theorem}{Theorem}
\begin{document}
\begin{theorem}[Pythagoras]
Suppose that \ldots
\end{theorem}
\end{document}