我正在尋找一種類似於本書中使用的定理樣式:
羅斯的初步分析
我已經完成了大部分工作,除了我想得到一個像這樣的自訂定理:
當我輸入類似以下內容:
\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}