如何更改 newtheorem 环境的 headfont 以匹配 komascript 字体?

如何更改 newtheorem 环境的 headfont 以匹配 komascript 字体?

我想更改定理环境 headfont 以匹配章节和部分中的 komascript 字体。我特别想知道如何使用类似 的包来做到这一点thmtools

这是MWE:

\documentclass{scrbook}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\newtheorem{thm}{Theorem}
\begin{document}
\section{Introduction to the theorem}

Introduction of something. Here's the theorem:

\begin{thm}
This is a theorem.
\end{thm}

\end{document}

输出如下

在此处输入图片描述

答案1

随着amsthm,看着https://tex.stackexchange.com/a/17555/4427其中列出了标准值:

\documentclass{scrbook}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsthm}

\newtheoremstyle{komaplain}
  {\topsep}   % ABOVESPACE
  {\topsep}   % BELOWSPACE
  {\itshape}  % BODYFONT
  {0pt}       % INDENT (empty value is the same as 0pt)
  {\bfseries\sffamily} % HEADFONT
  {.}         % HEADPUNCT
  {5pt plus 1pt minus 1pt} % HEADSPACE
  {}          % CUSTOM-HEAD-SPEC

\theoremstyle{komaplain}
\newtheorem{thm}{Theorem}

\begin{document}

\section{Introduction to the theorem}

Introduction of something. Here's the theorem:

\begin{thm}
This is a theorem.
\end{thm}

\begin{thm}[Note]
This is a theorem.
\end{thm}

\end{document}

在此处输入图片描述

答案2

使用thmtools您可以更改headfont如下内容:

在此处输入图片描述

\documentclass{scrbook}
\usepackage[utf8]{inputenc}
\usepackage{amsmath,amsthm}

\usepackage{thmtools}
\declaretheoremstyle[headfont=\sffamily\bfseries]{thm}
\declaretheorem[style=thm]{thm}

\begin{document}
\section{Introduction to the theorem}

Introduction of something. Here's the theorem:

\begin{thm}
This is a theorem.
\end{thm}

\end{document}

答案3

amsthm以下是包含和 的示例代码thmtools。请注意thmtools还与 配合使用ntheorem

\documentclass{scrbook}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsthm, thmtools}
\newtheorem{thm}{Theorem}
\declaretheoremstyle[%
spaceabove=6pt, spacebelow=6pt,%
headfont=\sffamily\bfseries,
notefont=\sffamily\bfseries, notebraces={(}{)},
headpunct =\,—,
bodyfont=\normalfont\itshape]%
{sf}
\declaretheorem[style=sf, within=chapter, name=Theorem]{theo}

\begin{document}

\setcounter{chapter}{3}
\section{Introduction to the theorem}

Introduction of something. Here's the theorem:

\begin{theo}[using a sans font]
This is a well-known theorem.
\end{theo}

\end{document} 

在此处输入图片描述

答案4

为了确保与headfontKOMA-Script 文档中的章节和节标题的字体设置相匹配,请使用

\usekomafont{disposition}

字体元素的初始定义disposition\normalcolor\sffamily\bfseries。但可以使用\setkomafont或进行更改\addtokomafont

\documentclass{scrbook}
\PreventPackageFromLoading{remreset}% comment this line, if you use an older TeX-Distribution
\usepackage[utf8]{inputenc}
\usepackage{amsmath,amsthm}

%\addtokomafont{disposition}{\rmfamily}

\usepackage{thmtools}
\declaretheoremstyle[headfont=\usekomafont{disposition}]{thm}
\declaretheorem[style=thm]{thm}

\begin{document}
\section{Introduction to the theorem}

Introduction of something. Here's the theorem:

\begin{thm}[Note]
This is a theorem.
\end{thm}

\end{document}

附加说明:thmtools加载已过时的包remreset,该包已过时,不适用于最新的 TeX 发行版。为了避免出现警告 »remreset包已过时:\@removefromreset已定义。«\PreventPackageFromLoading{remreset}示例中使用了 KOMA-Script 命令。

相关内容