# Comment Multi-line Text on Counter Condition

I have a document which I want to print in several (let's say 10) different versions. Some parts are just a draft, others are more or less finished, some are ready for publication and so on. I would like to associate a number between 1 and 10, called Release Level, to each part of the text. In the beginning I would like to specify a global Publication Level, let's say 5, and I want all parts of the text printed, which have a Release Level >=5.

Since there are already multiple packages available dealing with conditional printing I would like to use them to solve the problem. The following code uses comment.

Using \rlcheckstatus and rltext works fine as described below, but the environment rlctxt, which just combines both commands produces the error: ! File ended while scanning use of \next.<inserted text> \par

I tried to use versions instead, but this produces the same problem. Is there any way around that problem?

\documentclass{scrartcl}

\usepackage{ifthen}
\usepackage{comment}

\newcounter{rlpublvl}   %this counter stores the publication level
\newcommand{\rlstetpublvl}[1]{\setcounter{rlpublvl}{#1}}    %sets the publication level to #1
\newenvironment{rltext}{}{}
\newcommand{\rlcheckstatus}[1]{    %activates the environment rltext if #1 >= rlpublvl
\ifthenelse{#1 > \value{rlpublvl}}
{\includecomment{rltext}}
{\excludecomment{rltext}}
}

\newenvironment{rlctxt}[1]{\rlcheckstatus{#1}
\begin{rltext}}{\end{rltext}}

\begin{document}

\rlstetpublvl{5}    %global publication level set to 5

\rlcheckstatus{5} %this is printed
\begin{rltext}
\end{rltext}

\rlcheckstatus{0}  %this is not printed
\begin{rltext}
This part is still under construction.
\end{rltext}

\rlcheckstatus{7} %this is again printed
\begin{rltext}
This part is good again.
\end{rltext}

\begin{rlctxt}{3} %this does not work
foo
\end{rlctxt}

\end{document}

-

I believe this is a standard problem with verbatim/comment like macros that require the \begin and \end to appear explicitly in the code and things get complicated when they are are wrapped in an environment.

I would use the environ package to do this since you are already wrapping the content within an environment:

\NewEnviron{rlctxt}[1]{%
\ifthenelse{#1 > \value{rlpublvl}}%
{\BODY}%
{} %
}%


The \BODY is the body of the environment that only gets typeset under the appropriate condition.

## Code:

\documentclass{scrartcl}
\usepackage{environ}

\usepackage{ifthen}
\usepackage{comment}

\newcounter{rlpublvl}%   %this counter stores the publication level
\newcommand{\rlstetpublvl}[1]{\setcounter{rlpublvl}{#1}}%    %sets the publication level to #1

\newenvironment{rltext}{}{}%

\newcommand{\rlcheckstatus}[1]{%    %activates the environment rltext if #1 >= rlpublvl
\ifthenelse{#1 > \value{rlpublvl}}%
{\includecomment{rltext}}%
{\excludecomment{rltext}} %
}%

%\newenvironment{rlctxt}[1]{\rlcheckstatus{#1}
%    \begin{rltext}}{\end{rltext}}
\NewEnviron{rlctxt}[1]{%
%\rlcheckstatus{#1}%
\ifthenelse{#1 > \value{rlpublvl}}%
{\BODY}%
{} %
}%

\begin{document}

\rlstetpublvl{5}    %global publication level set to 5

\rlcheckstatus{5} %this is printed
\begin{rltext}
\end{rltext}

\rlcheckstatus{0}  %this is not printed
\begin{rltext}
This part is still under construction.
\end{rltext}

%-------

\begin{rlctxt}{5}%  %this is printed

@Meneldur: That seems like a very good question, so please new post a new question. You can link to this question if needed. That way it can benefit others who encounter a similar problem. Also, please keep in mind that it is always best to compose a fully compilable MWE that illustrates the problem including the \documentclass and the appropriate packages so that those trying to help don't have to recreate it. – Peter Grill Mar 25 '12 at 18:53