我正在尝试沙德姆包在阴影框中排版引理,但目前为止还失败了。
以下文件产生
\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage[normalem]{ulem}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage[margin=0.75in]{geometry}
\usepackage{blindtext}
\setlength{\parindent}{20pt}
\usepackage{amsthm}
\usepackage{shadethm}
\renewcommand\qedsymbol{$\blacksquare$}
\newshadetheorem{theorem}{Theorem}
\newshadetheorem{corollary}{Corollary}[theorem]
\title{\vspace{-1.5cm}Test Document}
\begin{document}
\maketitle
\blindtext
\begin{theorem}
This is a theorema about right triangles and can be summarised in the next
equation
\[ x^2 + y^2 = z^2 \]
\end{theorem}
\section{New Section}
\begin{theorem}[Pythagorean theorem]
\label{pythagorean}
This is a theorema about right triangles and can be summarised in the next
equation
\[ x^2 + y^2 = z^2 \]
\end{theorem}
\begin{proof}
To prove it by contradiction try and assume that the statemenet is false,
proceed from there and at some point you will arrive to a contradiction.
\end{proof}
\blindtext
\begin{corollary}
This is a theorema about right triangles and can be summarised in the next
equation
\[ x^2 + y^2 = z^2 \]
\end{corollary}
\end{document}
然而,当我尝试将引理排版为定理时
\newshadetheorem{lemma}[theorem]{Lemma}
(如下背面),然后使用\begin{lemma}...\end{lemma}
我收到编译错误
[long compilation output]
! TeX capacity exceeded, sorry [input stack size=5000].
\cl@theorem ->\cl@theorem
\@elt {shadecorollary}
l.57 \begin{lemma}
! ==> Fatal error occurred, no output PDF file produced!
Transcript written on test.log.
我哪里做错了?我希望定理和引理按顺序一起标记,如定理 1、引理 2、引理 3、定理 4,而不管它们位于哪个章节号。
答案1
您可能有兴趣尝试一下该ntheorem
软件包,它使您能够完全自定义定理的布局。对于阴影定理,它依赖于该framed
软件包。请注意,即使证明以方程式结尾(需要两次编译),也会自动放置“证明结束”符号:
\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[margin=0.75in]{geometry}
\usepackage{graphicx}
\usepackage[svgnames]{xcolor}
\usepackage[normalem]{ulem}
\usepackage{amsmath, amssymb, nccmath}
\usepackage{blindtext}
\setlength{\parindent}{20pt}
\usepackage{framed}
\usepackage[framed, thmmarks]{ntheorem}
\colorlet{shadecolor}{Gainsboro!50!Lavender}
\def\theoremframecommand{\colorbox{shadecolor}}
\theoreminframepreskip{\medskipamount}
\theoreminframepostskip{\medskipamount}
\theoremseparator{.}
\newshadedtheorem{theorem}{Theorem}
\newshadedtheorem{corollary}{Corollary}[theorem]
\newshadedtheorem{lemma}{Lemma}[theorem]
\theoremstyle{nonumberplain}
\theoremheaderfont{\itshape}
\theorembodyfont{\upshape}
\theoremseparator{:}
\theoremsymbol{\ensuremath{\blacksquare}}
\newtheorem{proof}{Proof}
\title{\vspace{-1.5cm}Test Document}
\author{My Self}
\date{}
\begin{document}
\maketitle
\blindtext
\begin{theorem}
This is a theorema about right triangles and can be summarised in the next
equation\useshortskip
\[ x^2 + y^2 = z^2 \]
\end{theorem}
\begin{lemma}
This lemma doesn’t provoke a general panic.
\end{lemma}
\section{New Section}
\begin{theorem}[Pythagorean theorem]
\label{pythagorean}
This is a theorema about right triangles and can be summarised in the next
equation
\[ x^2 + y^2 = z^2 \]
\end{theorem}
\begin{proof}
To prove it by contradiction try and assume that the statement is false,
proceed from there and at some point you will arrive to a contradiction. Hence
\[ a^2 = b^2 + c^2. \]%
\end{proof}
\blindtext
\begin{corollary}
This is a theorema about right triangles and can be summarised in the next
equation
\[ x^2 + y^2 = z^2 \]
\end{corollary}
\end{document}
答案2
从手册中看不是很清楚,但源文件(shadethm.sty
)有更多信息(从第 180 行开始):
The invocation possibilities are:
\newshadetheorem{NAME}{TEXT}[COUNTER]
e.g., \newshadetheorem{theorem}{Theorem}[section] meaning to allow
one to say \begin{theorem} $e=mc^2$ \end{theorem} to produce
Theorem 1.1.1 e=mc2
shaded and numbered by section.
\newshadetheorem{NAME}[OLDNAME]{TEXT}
e.g., \newshadetheorem{remark}[theorem]{Remark} meaning to allow
one to say \begin{remark} Obvious. \end{remark} to produce
Remark 1.1.2 Obvious.
shaded and numbered with the same counter used for theorems.
因此,当您想使用外部计数器来计数定理时,您可以将参数放在定理名称后面;而当您想使用内部计数器时,您可以将参数放在中间。
当您想在外部和内部使用同一个计数器时,似乎会出现错误。如果您想这样做,一个可能的解决方案是,不使用可选参数为新环境创建一个单独的计数器,然后通过重新定义显示宏(此处\theshadecorollary
)将定理计数器作为该计数器的前缀。
梅威瑟:
\documentclass[11pt]{article}
\usepackage{amsthm}
\usepackage{amssymb}
\usepackage{shadethm}
\renewcommand\qedsymbol{$\blacksquare$}
\newshadetheorem{theorem}{Theorem}
\newshadetheorem{corollary}{Corollary}
\newshadetheorem{lemma}[theorem]{Lemma}
% redefine display of corollary counter
\def\theshadecorollary{\arabic{shadetheorem}.\arabic{shadecorollary}}
% reset corollary counter when theorem counter is increased
\makeatletter
\@addtoreset{shadecorollary}{shadetheorem}
\makeatother
\title{Test Document}
\begin{document}
\maketitle
\begin{lemma}
This is a lemma
\end{lemma}
\begin{theorem}
This is a theorema about right triangles and can be summarised in the next
equation
\[ x^2 + y^2 = z^2 \]
\end{theorem}
\section{New Section}
\begin{theorem}[Pythagorean theorem]
\label{pythagorean}
This is a theorema about right triangles and can be summarised in the next
equation
\[ x^2 + y^2 = z^2 \]
\end{theorem}
\begin{proof}
To prove it by contradiction try and assume that the statement is false,
proceed from there and at some point you will arrive to a contradiction.
\end{proof}
\begin{corollary}
This is a theorema about right triangles and can be summarised in the next
equation
\[ x^2 + y^2 = z^2 \]
\end{corollary}
\begin{corollary}[Pythagorean theorem]
The following also holds:
\[ a^2 + b^2 = c^2 \]
\end{corollary}
\end{document}
结果: