我想更改定理环境 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
为了确保与headfont
KOMA-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 命令。