数字のフォントを に変更したいのですが\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}