I am writing an article with some embedded Sage code, using Sagetex for the purpose. Mostly it works well, with multiple uses of the sageexample environment. However, there are several things I'd like to be able to do:

  1. Decrease the space between the sage commands
  2. Have the "sage" keyword typeset in a different color (like in the sagecommandline environment)
  3. Alternatively, typeset the sagecommandline environment without line numbers.

The documentation, while probably complete, doesn't describe easy ways to do such things.

I also have the occasional Sage output which is different from when I run Sage in a notebook. Usually I check that the Sage commands give the result I want, then I put all the commands inside a sageexample environment and run latex-sage-latex on my file. But I'm finding sometimes the output typeset in my latex file is very different from what I see in the notebook. This is particularly noticeable with the various simplify commands. I can't seem to create a MWE, so I'm wondering if this is a known general problem, for which there's an easy fix?

  • 1
    Without an MWE, we can't help you on the last topic. And for the first three topics it would be nice to see a little example in order to see if the space between the environments is set correctly or not. Point 2: Maybe use listings instead. – LaRiFaRi Jun 5 '15 at 13:59

Locate the relevant bits in sagetex.sty. Then you have several options:

  • place a modified copy of sagetex.sty near your document,
  • in the latex preamble of your document, change the relevant bits using \makeatletter and \makeatother if necessary,
  • create an extra sty file with such changes, and \usepackage it after \usepackage{sagetex}.
| improve this answer | |

Those are really issues with the listings package and you should be able to deal with them reasonably without editing sagetex.sty or anything like that; see the example.tex file included in Sage which has an example of changing some of the colors.

For the line numbers, you'll need to consult the listings documentation and see how one turns the line numbers off.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.