TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
    
Another useful-looking package that I'd never heard of! – Loop Space Aug 14 '10 at 17:47
up vote 6 down vote accepted

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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