備註環境的斜體冒號(使用`amsthm`),但編號為正常字體

備註環境的斜體冒號(使用`amsthm`),但編號為正常字體

通常我不喜歡定理標題後面的點。因此,我在序言中添加了以下行:

\g@addto@macro{\thm@space@setup}{\thm@headpunct{:}}

效果很好。但是使用該選項,我會在標題後面得到一個斜體冒號remark,這在沒有編號時很好,但在啟用編號的情況下,數字以普通字體而不是斜體書寫。是否也可以將數字設定為斜體字體,或將冒號設定為正常字體不是定義新的定理風格?

我希望冒號在一種情況下採用正常字體,在另一種情況下同時採用斜體字體,或將數字轉換為斜體字體。

\documentclass{article}
\usepackage{amsthm}

\theoremstyle{remark}
\newtheorem{remark}{Remark}
\newtheorem*{remark*}{Remark}

\makeatletter
\g@addto@macro{\thm@space@setup}{\thm@headpunct{:}}
\makeatother

\begin{document}
    \begin{remark}
        Here is a numbered remark.
    \end{remark}
    \begin{remark*}
        Here is an unnumbered remark.
    \end{remark*}
\end{document}

在此輸入影像描述

更新:對我來說,在任何地方使用向上冒號的問題是未編號的斜體標題和冒號之間的間距。一切\/順利,請參閱下面的評論。

答案1

amsthm包內部定義了一個巨集\@upn來保持數字直立,無論頭部的字體如何。透過將其細化為空宏,數字將以頭部的字體列印。

\documentclass{article}
\usepackage{amsthm}

\theoremstyle{remark}
\newtheorem{remark}{Remark}
\newtheorem*{remark*}{Remark}

\makeatletter
\g@addto@macro{\thm@space@setup}{\thm@headpunct{:}}
\renewcommand{\@upn}{} % to use the same font for the number as for the head
\makeatother

\begin{document}
    \begin{remark}
        Here is a numbered remark.
    \end{remark}
    \begin{remark*}
        Here is an unnumbered remark.
    \end{remark*}
\end{document}

答案2

此類更改最好透過 來解決thmtools

\documentclass{article}
\usepackage{amsthm,thmtools}

\declaretheoremstyle[
  headfont=\normalfont\itshape,
  headpunct=\textup{:},
  bodyfont=\normalfont,
]{myremark}

\declaretheoremstyle[
  headfont=\normalfont\itshape,
  headpunct=:,
  bodyfont=\normalfont,
]{myremarknonum}

\theoremstyle{myremark}
\newtheorem{remark}{Remark}
\theoremstyle{myremarknonum}
\newtheorem*{remark*}{Remark}

\begin{document}

Some text to show the context. Some text to show the context.
Some text to show the context. Some text to show the context.
Some text to show the context.

\begin{remark}
Here is a numbered remark.
\end{remark}

\begin{remark*}
Here is an unnumbered remark.
\end{remark*}

\end{document}

在此輸入影像描述

老實說,在這兩種情況下我都更喜歡直立的結腸。

相關內容