5

I have written some remarks in some of my works that are somewhat informal and repetitive in nature (mainly for my own clarification). I was wondering if there is a way of suppressing them when I don't want to typeset them in the PDF.

MWE:

\documentclass{article}

\usepackage{amsmath,amsthm}

\newtheorem*{remark}{Remark}

\begin{document}

\section{Inner Loop (for $l$)}

We begin with inner loop - s.t. the given constraints, we find the optimal
level for individual labour supply in equilibirum,
\begin{equation*}
l=l^{\star }.
\end{equation*}

\begin{remark}
I want to keep this remark.
\end{remark}

\begin{remark}
When necessary, I would like to typeset this remark on or off.
\end{remark}

\end{document}

output

10

The comment package provides this functionality via the environment comment. One could also specify a new comment environment that could be included/excluded. See the comment package documentation for more information.

A more straight-forward way is to use conditionals in LaTeX:

  1. Define a \newif;
  2. Set the value to true to show the comments (say);
  3. Set the value to false to hide the comments (say).

Here's a minimal example that defines \ifkeepremark as a \newif and sets it to true (\keepremarktrue) or false (\keepremarkfalse) depending on whether you need it or not:

enter image description here

\documentclass{article}
\usepackage{amsmath}% http://ctan.org/pkg/amsmath
\newif\ifkeepremark
\begin{document}
\section{Inner Loop (for $l$)}

We begin with inner loop - s.t. the given constraints, we find the optimal
level for individual labour supply in equilibirum,
\begin{equation*}
  l=l^{\star}.
\end{equation*}

\keepremarktrue
\ifkeepremark
I want to keep this remark.
\fi

\keepremarkfalse
\ifkeepremark
When necessary, I would like to typeset this remark on or off.
\fi
\end{document}

It is possible to maintain the remark environment look using the environ package. It allows for environment definition in a control sequence style:

\usepackage{environ}% http://ctan.org/pkg/environ
\newif\ifkeepremark \keepremarktrue
\NewEnviron{remark}{\ifkeepremark\BODY\fi}

You could then still use

\begin{remark}
Here is a remark.
\end{remark}

together with the "switches" \keepremarktrue and \keepremarkfalse to selectively keep/discard remarks. The default value is \keepremarkfalse, which I've overridden with an issue of \keepremarktrue. That is, by default, all remarks will be visible.

You could also define your own remark environments based on other/alternative \newifs that you can turn on/off in the preamble (for a global modification).

|improve this answer|||||
  • Thanks. I'll have a look at comment package. Is it possible to have the standard look of Remark [or any environment] whilst using the requested feature? – bakul Feb 25 '12 at 0:51
  • 1
    @bakul: I've added the use of the environ package. That allows you to define a remark environment that you can use the conditionals with. – Werner Feb 25 '12 at 0:59

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.