I use package answers for putting answers or hints to problems at the end of a document. I wonder if it is possible to use the environment for solutions inside a command. But the straightforward way:
\documentclass[11pt,a4paper]{article}
\usepackage{amsthm}
\usepackage{answers}
\newtheorem{problem}{Problem}
\Newassociation{sol}{Sol}{solutions}
\newcommand{\shortsol}[1]{\begin{sol} #1\end{sol}}
\begin{document}
\Opensolutionfile{solutions}
\begin{problem}
This is problem.
\shortsol{42}
\end{problem}
\Closesolutionfile{solutions}
\section*{Solutions}
\input{solutions}
\end{document}
leads to the error:
Runaway argument?
! File ended while scanning use of \next.
<inserted text>
\par
I would appreciate if someone tells me if such a thing is possible. (I am trying to use solutions environments inside commands mainly for compatibility reasons. I have some other documents where the problems are written using commands, e. g. \problem{Statement}{Result is 42}
.)
sol
in the argument to a command, because it needs to do verbatim-like business.\begin{sol}42\end{sol}
instead of\shortsol{42}
and that works for me.