2

I want to hide some of the proofs of some lecture notes that are given to students. I defined a new proof environment hiddenproof because I want to only hide some of the proofs. I can then hide this environment (actually I'm replacing its content with the text "Will be presented in the lecture") via the environ package. That's all working well. However I'm using many equations and I'm also numbering them, here's a MWE:

\documentclass{scrartcl}

\usepackage{amsmath,amsthm,amssymb}

\renewenvironment{proof}{\noindent\textbf{Beweis.}\hspace*{1em}}{\qed\\}
\newenvironment{hiddenproof}{\noindent\textbf{Beweis.}\hspace*{1em}}{\qed\\}

\newif\ifhideproofs%
%\hideproofstrue%uncomment to hide proofs

\ifhideproofs%
  \usepackage{environ}
  \NewEnviron{hide}{\noindent\textbf{Beweis.}\hspace*{1em} In der Vorlesung.\hfill $\qed$\\[.5ex]}
  \let\hiddenproof\hide%
  \let\endhiddenproof\endhide%
\fi

\begin{document}

\begin{hiddenproof}
  Some proof.
  \begin{equation}%
    \label{eq:eq1}
    Ax = b
  \end{equation}
\end{hiddenproof} 

\begin{equation}
  \label{eq:eq2}
  Ax = c
\end{equation}

\end{document}

As the equation numbers are referenced in the lecture, I would like to keep them the same - No matter the proofs are visible or hidden. When the hiddenproof is not hidden, everything's fine: eq:eq1 will be labeled with (1) and eq:eq2 will be labeled with (2). However if I hide the proofs (by uncommenting \hideproofstrue), the first equation environment doesn't even exist anymore, and the second equation will get the label (1).

Is there any way to "count" all the equation environments (and align and gather) and increment the equation counter accordingly? Or maybe there's another way to hide some of the proofs so that the equation environments are not removed but rather made invisible.

  • 2
    Welcome to tex.sx. Without knowing how hiddenproof is defined, or what theorem package you're using, any attempt to answer this question is going to be pure speculation. Please add the needed information. – barbara beeton Mar 20 at 23:21
1

You could input the contents of the environment into a box that is never used. So every macro inside the environment is expanded (including counters) but never printed:

\ifhideproofs%
  \usepackage{environ}%
  \NewEnviron{hide}{\noindent\textbf{Beweis.}\hspace*{1em} In der Vorlesung.\hfill $\qed$\\[.5ex]%
    \setbox0\vbox{\BODY}% execute env without printing anything
  }
  \let\hiddenproof\hide%
  \let\endhiddenproof\endhide%
\fi
  • That's exactly what I wanted, thank you – Nils Friess Mar 21 at 12:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.