I have a document containing some proofs and want to create a version only containing the theorems (and corollaries and lemmas and examples and …), but no proofs at all.
Is there an easy, automatic way to do that?
amsthmenvironments
I have a document containing some proofs and want to create a version only containing the theorems (and corollaries and lemmas and examples and …), but no proofs at all.
Is there an easy, automatic way to do that?
You can use mdframed:
\documentclass{article}
\usepackage{amsthm}
\usepackage[framemethod=tikz]{mdframed}
\usepackage{lipsum}
\theoremstyle{plain}
\newmdtheoremenv[
linecolor=cyan,
roundcorner=5pt,
linewidth=1pt
]{theo}{Theorem}
\theoremstyle{definition}
\newmdtheoremenv[
hidealllines=true,
leftline=true,
innerleftmargin=10pt,
innerrightmargin=10pt,
innertopmargin=0pt,
]{defi}{Definition}
\begin{document}
\lipsum[4]
\begin{defi}
\lipsum[4]
\end{defi}
\lipsum[4]
\begin{theo}
\lipsum[4]
\end{theo}
\end{document}
The package offers many additional customization options; please refer to the package documentation which also contains numerous examples.
If a same style is to be used for several structures, then it's better to define a style to be used multiple times; the package also offers a very useful \surroundwithmdframed
command to apply mdframed settings to an already defined environment. In the following example I define a style, built an structure for definitions using this style, and surround the standard proof
environment (from amsthm
) with this style:
\documentclass{article}
\usepackage{amsthm}
\usepackage[framemethod=tikz]{mdframed}
\usepackage{lipsum}
\mdfdefinestyle{mystyle}{
hidealllines=true,
leftline=true,
innerleftmargin=10pt,
innerrightmargin=10pt,
innertopmargin=0pt,
}
\surroundwithmdframed[style=mystyle]{proof}
\theoremstyle{definition}
\newmdtheoremenv[style=mystyle]{defi}{Definition}
\begin{document}
\lipsum[4]
\begin{defi}
\lipsum[4]
\end{defi}
\lipsum[4]
\begin{proof}
\lipsum*[4]
\end{proof}
\end{document}
First let me show an example where \null\hfill\qedsymbol
doesn't do the right thing. Note that adding \null\hfill\qedsymbol
explicitly is the same as doing it with \AtEndEnvironment
, with the only difference that the indirect method does not take care of a possible space before \null
, making things worse.
\documentclass{amsbook}
\usepackage{amsthm}
\newtheorem{theorem}{Theorem}
\begin{document}
\begin{theorem}
Some long theorem statement,
long long long long long
long long long long long
long long long long long
long long long long
enough to show bad effect.\null\hfill\qedsymbol
\end{theorem}
\end{document}
You have several better choices for this. The simpler, in my opinion, is to append \qed
at the end of statements you don't give a proof of.
\documentclass{amsbook}
\usepackage{amsthm}
\newtheorem{theorem}{Theorem}
\begin{document}
\begin{theorem}
Some long theorem statement,
long long long long long
long long long long long
long long long long long
long long long long
enough to show bad effect.\qed
\end{theorem}
\end{document}
Same text as before, but the tombstone ends up where desired.
A different approach would be to define a different environment, say a *
-variant:
\documentclass{amsbook}
\usepackage{amsthm}
\newtheorem{theorem}{Theorem}
\newenvironment{theorem*}
{\pushQED{\qed}\theorem}
{\popQED\endtheorem}
\begin{document}
\begin{theorem*}
Some long theorem statement,
long long long long long
long long long long long
long long long long long
long long long long
enough to show bad effect.
\end{theorem*}
\end{document}
This has the disadvantage of requiring the *
in both the \begin
and \end
part, but has some advantages: you don't need to change the input in case you decide for suppressing those tombstones; you can easily change the tombstone for these cases.
A third possibility could be defining theorem
as an environment with a mandatory argument, like
\begin{theorem}{}
...<statement>...
\end{theorem}
when you don't want a tombstone and
\begin{theorem}{\qed}
...<statement>...
\end{theorem}
It could be arranged so as to support
\begin{theorem}
...<statement>...
\end{theorem}
\begin{theorem}\qed
...<statement>...
\end{theorem}
with the following trick:
\documentclass{amsbook}
\usepackage{amsthm}
\newif\ifstumpqed
\newtheorem{theoremInner}{Theorem}
\newenvironment{theorem}[1]
{\ifx#1\qed\stumpqedtrue\pushQED{\qed}\fi\theoremInner}
{\ifstumpqed\popQED\fi\endtheoremInner}
\begin{document}
\begin{theorem}
Some long theorem statement,
long long long long long
long long long long long
long long long long long
long long long long
enough to show bad effect.
\end{theorem}
\begin{theorem}\qed
Some long theorem statement,
long long long long long
long long long long long
long long long long long
long long long long
enough to show bad effect.
\end{theorem}
\begin{theorem}\qed\label{whatever}
Some long theorem statement,
long long long long long
long long long long long
long long long long long
long long long long
enough to show bad effect.
\end{theorem}
\begin{theorem}\qed[Whatever]\label{foo}
Some long theorem statement,
long long long long long
long long long long long
long long long long long
long long long long
enough to show bad effect.
\end{theorem}
\end{document}
If you have several of these declarations to manage, you can abstract the procedure:
\documentclass{amsbook}
\usepackage{amsthm}
\newcommand{\addqed}[1]{%
\expandafter\let\csname #1Inner\expandafter\endcsname\csname #1\endcsname
\expandafter\let\csname end#1Inner\expandafter\endcsname\csname end#1\endcsname
\expandafter\def\csname #1\endcsname##1{%
\ifx##1\qed\stumpqedtrue\pushQED{\qed}\fi\csname #1Inner\endcsname
}%
\expandafter\def\csname end#1\endcsname{%
\ifstumpqed\popQED\fi\csname end#1Inner\endcsname
}%
}
\newif\ifstumpqed
\newtheorem{theorem}{Theorem}[chapter]
\addqed{theorem}
\begin{document}
\begin{theorem}
Some long theorem statement,
long long long long long
long long long long long
long long long long long
long long long long
enough to show bad effect.
\end{theorem}
\begin{theorem}\qed
Some long theorem statement,
long long long long long
long long long long long
long long long long long
long long long long
enough to show bad effect.
\end{theorem}
\begin{theorem}\qed\label{whatever}
Some long theorem statement,
long long long long long
long long long long long
long long long long long
long long long long
enough to show bad effect.
\end{theorem}
\begin{theorem}\qed[Whatever]\label{foo}
Some long theorem statement,
long long long long long
long long long long long
long long long long long
long long long long
enough to show bad effect.
\end{theorem}
\end{document}
So, after a \newtheorem
declaration with the usual methods, add
\addqed{<env name>}
and you're done.
Best Answer
I personally use the
versions
package for this kind of work.Since I've commented here both
\excludeversion{prop}
and\excludeversion{dem}
out, boththm
andproof
environments appear:But if I choose to comment
\includeversion{dem}
and comment out\excludeversion{dem}
, it makes the proof disappear.The same will apply to all your
proof
environments if you've enclosed them in thisdem
environment defined byversions
.To the contrary, you can choose to make the
proof
environments stay and thethm
environments vanish if you apply the same maneuver to thosethm
environment (enclosing them in theprop
environment defined byversions
, commenting in/out the adequate lines:The wide variety of possibilities makes this solution most flexible.