3

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?

5
  • 1
    Did you use the proof environment?
    – egreg
    Feb 25, 2015 at 9:02
  • 5
    You can use comment package and \excludecomment{proof}.
    – Ignasi
    Feb 25, 2015 at 9:03
  • use this answer: tex.stackexchange.com/questions/106457/…
    – akraf
    Feb 25, 2015 at 9:06
  • @egreg: Yes, I do.
    – Keba
    Feb 25, 2015 at 9:36
  • @Ignasi: Thanks, that seems to be very easy. :)
    – Keba
    Feb 25, 2015 at 9:37

1 Answer 1

4

I personally use the versions package for this kind of work.

\documentclass[12pt]{scrartcl}
\usepackage{amsthm}
    \newtheorem{thm}{Theorem}

\usepackage{versions}
    \includeversion{prop}
    %\excludeversion{prop}
    \includeversion{dem}
    %\excludeversion{dem}

\usepackage{mathtools, amssymb, amsthm}

\begin{document}
\begin{prop}
    \begin{thm}
        \( (a+b)^2 = a^2 + 2ab + b^2\).
    \end{thm}
\end{prop}
\begin{dem}
    \begin{proof}
        \( (a+b)^2 = (a+b)(a+b) = a^2 + ab + ba + b^2 = a^2 + 2ab + b^2 \).
    \end{proof}
\end{dem}
\end{document}

Since I've commented here both \excludeversion{prop} and \excludeversion{dem} out, both thm and proof environments appear:

enter image description here

But if I choose to comment \includeversion{dem} and comment out \excludeversion{dem}, it makes the proof disappear.

\usepackage{versions}
    \includeversion{prop}
    %\excludeversion{prop}
    %\includeversion{dem}
    \excludeversion{dem}

enter image description here

The same will apply to all your proof environments if you've enclosed them in this dem environment defined by versions.

To the contrary, you can choose to make the proof environments stay and the thm environments vanish if you apply the same maneuver to those thm environment (enclosing them in the prop environment defined by versions, commenting in/out the adequate lines:

\usepackage{versions}
    %\includeversion{prop}
    \excludeversion{prop}
    \includeversion{dem}
    %\excludeversion{dem}

enter image description here

The wide variety of possibilities makes this solution most flexible.

5
  • Thanks, but does version have any advantages over comment?
    – Keba
    Feb 25, 2015 at 9:38
  • 1
    Excerpt from the documentation: Included environments never form groups in ‘comment’, here user may choose whether they form groups or not, at least for simple including (not with marks). ‘comment’ includes by writing on and reading from disk, present package needs no writing on disk… ‘Comment’ sometimes produces wrong spaces and discovers ‘\end{comment}’ only if nothing else is in the input line. Feb 25, 2015 at 9:49
  • @fpast From your answer (and a quick test) I understand that we need to surround proof and thm environments with external environments (prop and dem) in order to be excluded or included through versions package. Is not possible to use \excludeversion{thm}?
    – Ignasi
    Feb 25, 2015 at 10:32
  • @Ignasi Yes, it is possible to use \excludeversion{thm} with would result in the disappearance of every thm environments, but if you use \includeversion{thm} then only the contents of thm environments would be printed, without any feature coming from the amsthm package. For this reason, and at the cost of some more lines in my programs, I prefer surrounding the thm environment by another defined with versions (as dem here). Feb 25, 2015 at 11:12
  • @fpast Understood. Thank you for this reference to versions. I didn't know it.
    – Ignasi
    Feb 25, 2015 at 11:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .