I would like to be able to build a dynamic tikz picture using some random numbers generated via sage. Presently this seems to fail because tikz doesn't like the mathmode that sage has to be run inside of, but as I am just generating a simple integer number, latex shouldn't need mathmode to parse it. Thus I am wondering if there is a way to allow \sage (or any other command) to run outside of mathmode when it normally requires it (without digging all through the package to remove the requirement in the original definition).
I can't supply a MWE right now, but will edit with one in a couple hours if it's still needed.
sagetexrequires a 3 step compilation process: 1. Run LaTeX, 2. run Sage, 3. run LaTex using the data generated by Sage in step 2. Most mistakes come from calling\sagein the first pass because Sage hasn't run. One way to get around this is to make sure that the tikz code is generated during the Sage calculations in step 2. See, for example, my answer to plotting the Cantor function here. – DJP Apr 06 '18 at 15:34\documentclasscommand, have a minimal preamble and then\begin{document}...\end{document}. Ideally the code should compile, although it probably won't in this case, and be as small as possible to demonstrate your problem. If you give us code to start from it is much easier to help you -- and hence much more likely that some one will! – Apr 07 '18 at 05:54