4

I am using the versions.sty package and would like to process some text twice (or more times) in a different version configuration, but within the same document. So I use \excludeversion and \includeversion several times. Each use of these seems to define the environment with the same parameter as the name of the argument. So I get an annoying warning at every run, cluttering my LaTeX messages.

Here is a small example:

\documentclass{book}
\usepackage{versions}

\begin{document}

\includeversion{A}
\excludeversion{B}

\begin{A}a\end{A}
\begin{B}b\end{B}

\excludeversion{A}
\includeversion{B}

\begin{A}a\end{A}
\begin{B}b\end{B}

\end{document}

Produces the following warnings:

Package `Versions' Warning: Redefining environment `A' on input line 11.
Package `Versions' Warning: Redefining environment `B' on input line 12.

And the following output:

a
b

The output is fine. Is there a better way of doing what I am trying to achieve without this warnings?

(of course the idea is that the text that is repeated in MWE is included from the same file, so I obtain different run of latex over the same file).

  • You can either suppress the warnings, or try a different approach. Which do you want? Everybody may not be familiar with the versions package. Could you provide the expected output of your minimal example? – Werner Jan 28 '15 at 20:25
  • @Werner, I believe that it was an MWE already :) but I made it a tad more concrete. I would like best way to achieve multiple runs over the same sub-document, in different versions. Supressing warnings is much less interesting, unless any other alternative is awfully complex. – Andrzej Wąsowski Jan 28 '15 at 20:32
4

You can suppress the warnings issued by versions by adding the following to your preamble:

\makeatletter
\let\@Vs@envwarn\@gobble% Remove environment renewal warnings.
\makeatother

Alternatively the silence package does something similar:

\usepackage{silence}
\WarningFilter{`Versions'}{Redefining environment}

A different approach that uses \if-constructions would be:

\documentclass{article}
\newif\ifVersionA
\newif\ifVersionB
\begin{document}

\VersionAtrue% Include Version A
\VersionBfalse% Exclude Version B

\ifVersionA a \fi
\ifVersionB b \fi

\VersionAfalse% Exclude Version A
\VersionBtrue% Include Version B

\ifVersionA a \fi
\ifVersionB b \fi

\end{document}

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.