我想将数字的字体改为\itshape
,例如,我想得到 Theorem {\itshape 1.1}。有没有办法在 theorem 环境中做到这一点
答案1
假设您仅在文档中使用该amsthm
包,则可以这样做。
如果您只希望此行为适用于“简单”定理样式,请在序言中添加以下几行以重新定义简单样式:
\makeatletter
\renewcommand{\th@plain}{%
\renewcommand\@upn{\textit}%
\itshape%
}
\makeatother
您就完成了。
平均能量损失
\documentclass{article}
\usepackage{amsthm}
\makeatletter
\renewcommand{\th@plain}{%
\renewcommand\@upn{\textit}%
\itshape%
}
\makeatother
\newtheorem{thm}{Theorem}[section]
\begin{document}
\section{Test}
\begin{thm}
This is a theorem.
\end{thm}
\end{document}
输出
相反,如果你想要所有定理样式都具有这种行为,请将上述代码替换为
\makeatletter
\renewcommand\@upn{\textit}
\makeatother
平均能量损失
\documentclass{article}
\usepackage{amsthm}
\makeatletter
\renewcommand\@upn{\textit}
\makeatother
\newtheorem{thm}{Theorem}[section]
\theoremstyle{remark}
\newtheorem{rmk}[thm]{Remark}
\begin{document}
\section{Test}
\begin{thm}
This is a theorem.
\end{thm}
\begin{rmk}
And this is a remark.
\end{rmk}
\end{document}
输出
答案2
下面是一个带封装的方法ntheorem
,我重新定义了一下plain
样式:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage[amsthm, thmmarks, thref]{ntheorem}
\usepackage{cleveref}
\makeatletter
\renewtheoremstyle{plain}%
{\item[\hskip\labelsep \theorem@headerfont ##1\ \textit{##2}\theorem@separator]}%
{\item[\hskip\labelsep \theorem@headerfont ##1\ \textit{##2}\ (##3)\theorem@separator]}
\makeatother
\newtheorem{thm}{Theorem}[section]
\begin{document}
\section{A first section}
\begin{thm}\label{testthm}
This is a test theorem.
\end{thm}
We see in \cref{testthm}…
\end{document}
答案3
如果你没有使用专门用于定理的包,你可以这样做
\documentclass{article}
\usepackage{etoolbox}
\makeatletter
\patchcmd{\@opargbegintheorem}{#2}{\textit{#2}}{}{}
\patchcmd{\@begintheorem}{#2}{\textit{#2}}{}{}
\makeatother
\newtheorem{thm}{Theorem}
\begin{document}
\begin{thm}
Something
\end{thm}
\end{document}