我正在寻找类似本书中使用的定理风格:
罗斯的基本分析
我已经完成了大多数工作,除了我想要获得这样的自定义定理:
当我输入类似以下内容时:
\begin{thm}[Rational Zeros Theorem]
...
\end{thm}
我想要的其余样式是:
- 将数字和定理互换
- 在定理或定义的开头后面有一个换行符
- 用粗体代替斜体显示“证明。”并在其后添加换行符
- 如果证明以列表开头,则也会有换行符
我已经在尝试实现 1、2 和 3,如果您有兴趣,可以在 github 上找到它:https://github.com/kasperpeulen/Ross-Theorem-Style
我还没有解决 4,但是我在这里找到了一些其他帖子,所以我想我可以自己解决这个问题,但是当然,任何帮助都会受到赞赏。
答案1
好的,我现在可以工作了,感谢这个网站上的其他帖子,以及聊天中 percusse 的帮助:
以下是代码,您也可以在这里找到: https://github.com/kasperpeulen/Ross-Theorem-Style
\documentclass[12pt]{article}
\usepackage{amsmath, amssymb, amsthm}
\newtheoremstyle{theorem}% name
{}% Space above, empty = `usual value'
{}% Space below
{\itshape}% Body font
{}% Indent amount
{\bfseries}% Head font
{.}% Punctuation after head
{\newline}% Space after head: \newline = linebreak
{\def\temp{#3}\ifx\temp\empty\thmnumber{#2 }\thmname{#1}\else\thmnumber{#2}\thmnote{ #3}\fi}% Head spec
\theoremstyle{theorem}
\newtheorem{thm}{Theorem}[section]
\newtheorem{prop}[thm]{Proposition}
\newtheorem{lem}[thm]{Lemma}
\newtheorem{cor}[thm]{Corollary}
\swapnumbers
\newtheoremstyle{definition}% name
{}% Space above, empty = `usual value'
{}% Space below
{}% Body font
{}% Indent amount
{\bfseries}% Head font
{.}% Punctuation after thm head
{\newline}% Space after head: \newline = linebreak
{}% Head spec
\theoremstyle{definition}
\newtheorem{defn}[thm]{Definition}
\newtheorem{example}[thm]{Example}
\theoremstyle{remark}
\newtheorem{remark}[thm]{Remark}
%Makes "Proof." boldface
\makeatletter
\renewenvironment{proof}[1][\proofname] {\par\pushQED{\qed}\normalfont\topsep6\p@\@plus6\p@\relax\trivlist\item[\hskip\labelsep\bfseries#1\@addpunct{.}]\mbox{}\\*}{\popQED\endtrivlist\@endpefalse}
\makeatother
%Fix if theorem starts with a list
\makeatletter
\def\itemfix{%
\if@inlabel
\noindent \par\nobreak\vskip-\baselineskip\hrule\@height\z@
\fi}
\let\olditemize\itemize
\def\itemize{\itemfix\olditemize}
\makeatother
\makeatletter
\def\enumfix{%
\if@inlabel
\noindent \par\nobreak\vskip-\baselineskip\hrule\@height\z@
\fi}
\let\oldenumerate\enumerate
\def\enumerate{\enumfix\oldenumerate}
\begin{document}
\section{Some examples}
\begin{defn}
Here is a definition of \emph{something}.
\end{defn}
\begin{thm}[Intermediate Value Theorem]
This is a theorem with a name and with a number.
\end{thm}
\begin{thm}
This is a theorem without name and with a number.
\end{thm}
\begin{proof}
Here is the proof.
\end{proof}
\begin{thm}
\begin{enumerate}
\item Theorem that starts with a list.
\item Which seems to work.
\end{enumerate}
\end{thm}
\begin{thm}
\begin{itemize}
\item Theorem that starts with a list.
\item Which seems to work.
\end{itemize}
\end{thm}
\end{document}
答案2
这是一个简单的解决方案ntheorem
– 它的优点是可以自动放置end-of-proof
(可定制的)符号,即使证明以显示(组)方程式结束:
\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{amssymb}
\usepackage{mathtools, nccmath}
\usepackage{enumitem}
\usepackage[thmmarks, thref, amsmath]{ntheorem}
\makeatletter
\renewtheoremstyle{changebreak}%
{\item[\rlap{\vbox{\hbox{\hskip\labelsep \theorem@headerfont
##2\ ##1\theorem@separator}\hbox{\strut}}}]}%
{\item[\rlap{\vbox{\hbox{\hskip\labelsep \theorem@headerfont
##2\ ##3\theorem@separator}\hbox{\strut}}}]}
\makeatother
\theoremstyle{changebreak}
\theoremseparator{. }
\theoremheaderfont{\upshape\bfseries}
\theorembodyfont{\itshape}
\newtheorem{thm}{Theorem}[section]
\theorembodyfont{\upshape}
\newtheorem{defi}[thm]{Definition}
\theoremstyle{nonumberbreak}
\theoremseparator{}
\theoremsymbol{\ensuremath{\blacksquare}}
\newtheorem{proof}{Proof}
\begin{document}
\section{A First Section}
\begin{thm}
A numbered, unnamed theorem.
\end{thm}
\begin{thm}[Rational Zeros Theorem]
Suppose $ c_0 ,c_1 ,\dots, c_n $ be integers and $ r $ a rational number satisfying the polynomial equation.
\begin{equation}\label{intpol}
c_n xⁿ + c_{n-1} x^{n-1} + ... +c_1 x + c_0 =0
\end{equation}
where $ n ≥ 1$, $ c_{n} \ne 0$ and $ c_0 \ne 0 $. Let $ r = \mfrac{c}{d}$, where $ c, d $ are integers having no common factors and $ d \ne 0 $. Then $ c $ divides $ c_0 $ and $ d $ divides $ c_n $.
\end{thm}
\begin{proof}
\begin{itemize}[wide = 0pt]
\item[\em First proof.]
Left as an exercise.
\item[\em Second proof.] We deduce from the hypothesis that
\begin{align*}
& c_{n}cⁿ + c_{n-1}c^{n-1}d + ... + c_1 cd^{n-1} + c_0 dⁿ = 0, \\
\intertext{which we may rewrite as}
& c(c_{n}c^{n-2} + c_{n-1}c^{n-2}d + ... + c_1 d^{n-1}) = -c_0 dⁿ\\
\shortintertext{or}
& d(c_{n-1}c^{n-1} + ... + c_1 cd^{n-2} + c_0 d^{n-1}) = -c_{n}cⁿ.
\end{align*}
\end{itemize}
\end{proof}
\begin{defi}
A \textbf{rational function} is the quotient of two polynomial functions.
\end{defi}
\end{document}