Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Hello, @Shreya!

When you compile your LaTeX document, SageTeX extracts all the Sage code in a separate file. This file contains all the information of what should be computed, how to compute it, and where to write it. However, the file is not automatically executed. I think this is a security measure, since it would be unwise to automatically execute Sage code from a LaTeX file from an unknown or untrusted source. If that were the case, you would have all the code extracted, you can read it and then execute it if you trust it.

What you have to do is to manually execute that file (if you are using a TeX IDE, like TeXstudio, you can make that process automatic or configure it for a shortcut). For example, if your LaTeX document is called "hello_world.tex", after you run latex or pdflatex or lualatex, you will see a file called "hello_world.sagetex.sage". Go to your terminal and execute

sage hello_world.sagetex.sage

You will see a quite verbose output printed in your screen. If everything goes right, you will now have a file called "" and another called "heel_world.sagetex.out" (and perhaps other similar). That's it! Re-compile your LaTeX document, and you will see the output you needed automatically typeset in your file.

I hope this helps! Feel free to ask any doubt you have.

And welcome to the marvelous world of SageMath!