7

I just found out about the versions package here and am interested in using it to hide solutions in a problem set document. Recall that, to create versions block, in the preamble, you need

\usepackage{versions}  
\excludeversion{sol}  
%\includeversion{sol}

and, in the document,

\begin{sol} ... \end{sol}

Here, the blocks labeled "sol" will be excluded.

In my document, I define a new environment "Solution" as

\newenvironment{Solution}{\begin{sol} \\ \textbf{Solution: }}{\end{sol}}

This construction works perfectly if I instruct LaTeX to include the "sol" blocks, but chokes if I try to exclude them. For example, the following code chokes and gives an Incomplete \iffalse error:

\documentclass{article}  
\usepackage{versions}  
\excludeversion{sol}  
%\includeversion{sol}  
\newenvironment{Solution}{  
  \begin{sol}\\ \textbf{Solution: }}{  
  \end{sol}}  
\begin{document}  
\section{Question 1}  
What is $2+2$?  
\begin{Solution}  
It is $2+2=4$.  
\end{Solution}  
\end{document}

If I change the commenting and include "sol", then this code works as expected. I'm guessing that there's something going on with the way that the versions package works. Any suggestions?

1
  • Another useful-looking package that I'd never heard of! Aug 14, 2010 at 17:47

1 Answer 1

6

Don't use \begin{sol} ... \end{sol} in the definition of the Solution environment. \begin ... \end blocks don't nest very well. Rather, use \sol ... \endsol. Thus:

\documentclass{article}
\usepackage{versions}
\excludeversion{sol}
%\includeversion{sol}
\newenvironment{Solution}{
\sol\\ \textbf{Solution: }}{
\endsol}
\begin{document}
\section{Question 1}
What is $2+2$?
\begin{Solution}
It is $2+2=4$.
\end{Solution}
\end{document}

works.

You must log in to answer this question.

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