In a thread on creating random exams with SageTeX<https://groups.google.com/forum/?hl=en&fromgroups=#!topic/sage-edu/DSOk7CH4wB8>, I got the idea to make my own .sty file that does some setup and running of Sage commands for me, and lest me define ways to generate random problems, permute them, and so on. The problem I'm having is that I can't get SageTeX to play nicely with either \newcommand or \def, which obviously sabotages my efforts before I even begin. For instance, I'd want to be able to do things like \newproblem{...various args...} and have sagesilent blocks executed that create and store problem objects for later recall.
But here's what goes wrong. This file does exactly what you'd expect; it's a trivially tiny SageTeX document: \documentclass{article} \usepackage{sagetex} \begin{document} Testing to see what $1+1$ is: $\sage{1+1}$ \end{document} This file also typesets correctly and does what you'd expect: \documentclass{article} \usepackage{sagetex} \begin{document} Testing to see what $1+1$ is: \begin{sageblock}1+1\end{sageblock} \end{document} (It doesn't compute the result, but that's not important right now.) This file is my first use of \def with SageTeX, and it works fine. \newcommand works fine in this context as well. \documentclass{article} \usepackage{sagetex} \def\test{\sage{1+1}} \begin{document} Testing to see what $1+1$ is: \test \end{document} But this file does not: \documentclass{article} \usepackage{sagetex} \def\test{\begin{sageblock}1+1\end{sageblock}} \begin{document} Testing to see what $1+1$ is: \test \end{document} The error is this: Runaway argument? \end {document} ! File ended while scanning use of \next. <inserted text> \par The same error occurs if I use \newcommand instead of \def. Any tips on how I can get past the fact that I can't make commands that use SageTeX? -- You received this message because you are subscribed to the Google Groups "sage-edu" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-edu+unsubscr...@googlegroups.com. To post to this group, send email to sage-edu@googlegroups.com. Visit this group at http://groups.google.com/group/sage-edu?hl=en. For more options, visit https://groups.google.com/groups/opt_out.