I'm using sagetex to output the result of computations directly on LaTeX. I'm using Kile as my editor. The usual procedure for compilation is:

  1. compile LaTeX on Kile.
  2. goto terminal and load the Sage script on Sage
  3. compile LaTeX again.

I was wondering if it is possible to make a build tool for Kile that does, for example:

  1. pdflatex filename.tex
  2. sage filename.sagetex.sage
  3. pdflatex filename.tex

To create or modify build tools, go to Settings --> Configure Kile, and select Tools --> Build in the left panel. You have to create two new tools, one for just running sage filename.sage, one for the sequence of tools.

Tool for running sage

  1. Click the New button below the list of existing tools, call the new tool for example Sage.
  2. Click Next and then Finish, you don't have to specify the class.
  3. In the General tab for the new tool, type sage as the command, and '%S.sage' as an option. %S is, as I understand it, a placeholder for the filename without extension. (I just looked at how other tools, e.g. MakeIndex, is set up.)

In the Advanced tab you can fill in source and target extension, but I do not know if this is necessary to include. If it is, I guess the source extension is sage and the target sout. (According to http://www.sagemath.org/doc/tutorial/sagetex.html)

Tool for the sequence

  1. Create a new tool with a reasonable name, but this time select Quick build as the class.
  2. In the General tab, you can choose from existing tools, and combine these in a sequence. Select tool you want from the drop-down menu and click Add to add it to the sequence. Add the PDFLaTeX tool twice, and the Sage tool you just created in between.

The new tool is found under Build --> Other. You can add a keyboard shortcut if you like, by going to Settings --> Configure Shortcuts.

| improve this answer | |
  • I have Sage installed and went through the instructions but it didn't work. In "Tool for running sage", I change '%S.sagetex.tex' to '%S.sage' and then it worked but for some strange reason clicking on the ViewPDF button key now gives an error ("ViewPDF failed to start"). If I double-click on the PDF it opens and I can see the changes. With the PDF open compiling using the sequence works perfectly. PS: I didn't fill in source and target. +1! – DJP Feb 7 '13 at 1:26
  • @DJP Thanks for testing. First of all, I see that I made a silly mistake, according to the question it should be filename.sagetex.sage, not filename.sagetex.tex. Second, reading on sagemath.org, I see that sagetex produces a file called filename.sage, not filename.sagetex.sage, so the OP apparently made a mistake. I'll fix it immediately. No idea why the ViewPDF failed though. – Torbjørn T. Feb 7 '13 at 8:10
  • @TorbjørnT. Thanks for the instructions. For some reason, in my case, the sage script has extension .sagetex.sage. Just as a personal preference, on the tool for sequence under the tab Menu, I selected Add to Build menu: Compile. That way I have easy access along with the other tools for compilation – Prastt Feb 7 '13 at 19:48
  • @Barefeg: Adding a button to do a 1 touch compile (as opposed to the keyboard shortcut) is a useful touch. Thanks. I will have to start using Kile more. – DJP Feb 7 '13 at 23:40

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.