# Is there a workaround for Packages Comment and Sagetex incompatibility?

I use the "Comment package" to write exercises with or without solutions. But I also want to use the "Sagetex package" to write the solution without typos. There seems to be an incompatibility between the Comment package and the Sagetex one. I get the following cryptic message: "Bad space factor (0). \end{comment}" What does the message mean and is there a way to workaround this?

MWE:

\documentclass{article}
\usepackage{sagetex}
\usepackage{comment}
\begin{document}
This sentence
\begin{comment}
has
\end{comment}
no verb.
\end{document}

The packages should be loaded in reverse order:

\documentclass{article}
\usepackage{comment}
\usepackage{sagetex}

\begin{document}
This sentence
\begin{comment}
has
\end{comment}
no verb.
\end{document}

In any case the conditional compilation with a declared environment:

\includecomment{thisone}
\excludecomment{notthisone}

\documentclass{article}
\usepackage{comment} %allows conditional compilation
\usepackage{sagetex}%For computing with SAGE within the text
\includecomment{thisone}
\excludecomment{notthisone}

\begin{document}
This sentence
\begin{comment}
has
\end{comment}
no verb.
Check for\begin{notthisone}
superfluous
\end{notthisone}
spaces and around
\begin{thisone}
inclusion
\end{thisone}
of proper texts.
\end{document}
• Remember to mark your own answer as accepted. – Pablo González L Nov 23 '19 at 15:59