如何自訂 \newtheorem

如何自訂 \newtheorem

我想知道是否有辦法在使用 \newtheorem 命令建立的環境中刪除斜體文字格式。

這是我的程式碼:

\newtheorem{teorema}{Teorema}[subsection]

\begin{document}

\begin{teorema}
    This is a new theorem.
\end{teorema}

這是結果:

在此輸入影像描述

問題是我不希望文字是斜體的。我怎樣才能做到這一點?

答案1

如果你使用的話,這相當容易amsthm

\documentclass[a4paper]{article}
\usepackage{amsmath}
\usepackage{amsthm}

\theoremstyle{definition}
\newtheorem{teorema}{Teorema}[subsection]

由於幾個原因,我不建議根據小節對定理進行編號。首先,你必須使用小節,但這並不總是必要的;其次,如果課程有章節,你最終會得到定理數字。

我也不建議使用直排字體,因為斜體提供了視覺線索,可以更輕鬆地找到語句。

答案2

其工作方式\newtheorem以及可修補的定義環境\newtheorem取決於文件​​類別和所使用的套件。

使用文章類別並且不使用套件,您可以執行以下操作:

\documentclass{article}

\newtheorem{teorema}{Teorema}[subsection]
\makeatletter
\@ifdefinable\Oldteorema{\let\Oldteorema=\teorema}%
\renewcommand\teorema{\@ifnextchar[{\teoremaopt}{\Oldteorema\normalfont}}%
\newcommand\teoremaopt[1][]{\Oldteorema[{#1}]\normalfont}%
\makeatother

\begin{document}

\begin{teorema}
    This is a new theorem.
\end{teorema}

\begin{teorema}[someone]
    This is a new theorem.
\end{teorema}


\end{document}

我不保證這適用於其他文件類,例如,beamer。

您是否考慮過使用amsthm 包及其\newtheoremstyle/ \theoremstyle-指令?

相關內容