I want to create a package for formatting problem sets. Also, I want an easy way to produce versions with the problem statement and the solutions and versions with only the problem statements. I have something almost like what I want (see below). The only thing going wrong is that I don't get the "Begin Solution ... End Solution" when I include the solutions (I do get the "solution text goes here"). Note that I want the problem environment to change based on whether the solutions are included or not, which is why I had my own \IncludeSolutions command wrapped around the \includeversion command. Any suggestions on how to make this work? I'm also not particularly attached to this approach, so let me know if there is a superior way of approaching the problem. I myself thought of a better way to do this would be to use kvoptions to pass an argument to my package, and then define my problem/solution environments based on the argument, rather than using a separate command to redefine the problem environment, but I couldn't get this to work, either.
I define the commands in MyProblemSet as follows.
\ProvidesPackage{MyProblemSet}
\RequirePackage{versions}
\newenvironment{problem}
{
\textbf{Begin Problem (without solution)}:\\
}
{
\\\textbf{End Problem (without solution)}\\
}
\newenvironment{solution}
{
\textbf{Begin Solution}:\\
}
{
\\\textbf{End Solution}\\
}
\excludeversion{solution}
\newcommand{\IncludeSolutions}
{
\renewenvironment{problem}
{
\textbf{Begin Problem (with solution)}:\\
}
{
\\\textbf{End Problem (with solution)}\\
}
\includeversion{solution}
}
Here is an example of how I would like to use them.
\documentclass{article}
\usepackage{MyProblemSet}
\IncludeSolutions
\begin{document}
\begin{problem}
problem text goes here
\end{problem}
\begin{solution}
solution text goes here
\end{solution}
\end{document}
\usepackage{etoolbox}to create\newtoggle{includesolutions}. Create yoursolutionenvironment with\NewEnvironfrom\usepackage{environ}and put the toggle around your text and the\BODY. – Ethan Bolker Jun 23 '13 at 01:20answersis my favourite. Of course, that's not to say that you shouldn't create your own.... One thing to be careful of- you need to use%in some of your environment definitions to avoid extra vertical space – cmhughes Jun 23 '13 at 01:35exampackage/class. The\[no]printanswersmacro does what you need. – Sean Allred Jun 23 '13 at 01:48