Ask Your Question

How "run a .sage file"?

asked 2012-04-22 15:56:12 +0200

murray gravatar image

I'm trying to use the sagetex style file in LaTeX. After trying to process the example.tex file provided with sagetex, I get error messages in the log that say to "Run Sage on example.sagetex.sage".

On my OS X system, Sage is installed as a clickable .app. After I start the app, I know how to start a Terminal command session of Sage by using the right-click menu from the Sage icon in the dock.

But how do I process such a .sage file in there?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2012-04-22 23:04:42 +0200

If your Sage app is /Applications/, for example, then from a Terminal window, run

$ /Applications/ example.sagetex.sage

You can instead add the directory /Applications/ to your $PATH, and then you'll be able to do

$ sage example.sagetex.sage

Actually, once you add the sage directory to your $PATH, if you have latexmk, you can just do

$ latexmk example.tex

and it will run LaTeX and sage as many times as needed for the document (and also bibtex and any other needed TeX components).

edit flag offensive delete link more


I didn't know latexmk will run sage for you. Does it need special configuration, because the one I have installed (from MacTeX) doesn't seem to do it automatically?

Ivan Andrus gravatar imageIvan Andrus ( 2012-04-25 04:52:09 +0200 )edit

Hmm. I seem to have some customizations in my .latexmkrc file, apparently downloaded from

John Palmieri gravatar imageJohn Palmieri ( 2012-04-25 11:27:51 +0200 )edit

I should have thought to look there. Thanks.

Ivan Andrus gravatar imageIvan Andrus ( 2012-04-25 13:58:33 +0200 )edit

On my machine, this setting (with others) was also available in `[TexLive2011Path]/texmf-dist/doc/support/latexmk/example_rcfiles `

T. Verron gravatar imageT. Verron ( 2012-06-23 05:19:26 +0200 )edit

I would also add `push @generated_exts, "sage";`to the .latexmkrc file, it should prevent latexmk from trying to run sage on the .sage file before the first latex run (useful in case there was a syntax error in your sage code for example).

T. Verron gravatar imageT. Verron ( 2012-06-23 05:35:10 +0200 )edit

answered 2012-04-25 13:57:12 +0200

Ivan Andrus gravatar image

If you just double-click the sage file that will run it with

If you use Emacs and AUCTeX, then I'm working on support for automatically detecting and running Sage as necessary, together with support for automatically finding the sage executable in

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2012-04-22 15:56:12 +0200

Seen: 10,205 times

Last updated: Apr 25 '12