sagemath / sagetex

Embed code, results of computations, and plots from the Sage mathematics software suite (https://www.sagemath.org) into LaTeX documents. Source repository for https://pypi.org/project/sagetex/ and https://ctan.org/pkg/sagetex
https://ctan.org/pkg/sagetex
Other
58 stars 22 forks source link

```\sagestr``` seems (subtly) broken #13

Open EmmanuelCharpentier opened 7 years ago

EmmanuelCharpentier commented 7 years ago

The Pascal's triangle example on example.tex wokks. But this much simpler minimal example :

\documentclass{article}
\usepackage{sagetex}
\begin{document}

Sage won't admit that 2+2=\sagestr{2+2}. Ouch\,!

\end{document}

%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:

won't compile. The initial latex compilation fails with the following error :

ERROR: Missing $ inserted.

--- TeX said ---
<inserted text> 
                $
l.5 Sage won't admit that 2+2=\sagestr{2+2}

            .                                                            Ouch\,!
--- HELP ---
TeX probably found a command that can be used only in math mode when
it wasn't in math mode.  Remember that unless stated otherwise, all
all the commands of Section 3.3 in LaTeX Book (Lamport) can be used
only in math mode. TeX is not in math mode when it begins processing
the argument of a box-making command, even if that command is inside a
math environment. This error also occurs if TeX encounters a blank
line when it is in math mode.

Modifying the same minimal example to use \sage works, of course :


\documentclass{article}
\usepackage{sagetex}
\begin{document}

Sage will admit that $2+2=\sage{2+2}$. Aaaahhh\,!

\end{document}

%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End: