Question: Is there an environment similar to the comment environment that suppresses text and space but can be called using inline commands?
I'm trying to develop a better way to type my solutions into my homework sets. Ideally, I'd like to have something in the preamble that I comment/uncomment to include/exclude solutions. I have a MWE below to demonstrate the type of thing I'm trying to implement, but of course, in it's current form, it doesn't work.
\documentclass[12pt]{article}
\newenvironment{solution}{}{}
\newcommand{\soln}{\begin{solution}}
\newcommand{\solnend}{\end{solution}}
\newcommand{\nosolutions}{
\renewcommand{\soln}{\begin{comment}}
\renewcommand{\solnend}{\end{comment}}
}
%\nosolutions
\begin{document}
What is a question?
\soln
Not an answer.
\solnend
\end{document}
I know of one way to partially succeed in what I'm trying to do, and that is to define the new command with an optional argument. The issue I have with this is that when I have a problem with multiple parts that is quite long, it may take a non-trivial amount of time to actually locate the relevant part of the code (for reference, I'm using WinEdt paired with Sumatra, so I can double click the pdf in Sumatra and it takes me to that part of the code; with an optional argument, though, I'm always taken to the very end). A MWE demonstrating this method is below.
\documentclass[12pt]{article}
\newenvironment{solution}{}{}
\newcommand{\soln}[1]{\begin{solution}#1\end{solution}}
\newcommand{\nosolutions}{
\renewcommand{\soln}[1]{}
}
\nosolutions
\begin{document}
What is a question?
\soln{
Not an answer.
}
\end{document}
The ending question: is there anything like the comment environment available that suppresses text and space?
\includecomment{solution}
(or\excludecomment{solution}
) and just using\begin{solution}
and\end{solution}
everywhere? (Why is it that you insist on "inline commands" instead of "environments"?)\excludecomment{solution}
in one of my attempts, but I couldn't get the file to compile. To answer the second question: there is no particular reason, it was just simply my goal.comment
package?