如何改變定理後數字的字體

如何改變定理後數字的字體

我想將數字的字體更改為\itshape,例如我想得到 Theorem {\itshape 1.1}。有沒有辦法在定理環境中做到這一點

答案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}

在此輸入影像描述

相關內容