Integrating SAGE and Kile

If you use sagetex then you know the drill: run latex on the tex file to create a sage file and then open up the Sage terminal and load the sage file. If there were no errors along the way then run latex on the tex file to get the document. You can simplify the process a bit if you use the LaTeX editor Kile. Here's a step by step guide, with pictures.

Open Kile; go to Settings --> Configure Kile, and select Tools --> Build in the left panel.

KileSage1After clicking on build, click on the button "New..."; this will open up a panel where you will type a descriptive name for the tool. I've typed in SAGE.

KileSage2Press the "Next" button. After typing in the name, press the "Next" button.

KileSage3There's no need to specify the class; just click on "Finish".

Now 2 new tools need to be created: one for just running sage filename.sage, one for the sequence of tools. In the General tab for the new tool, type sage as the command, and '%S.sage' as an option.

KileSage5At this point we've told Kile how to compile with Sage. Now it's time to create a tool that will chain together 4 commands: pdflatex, sage, pdflatex, view the PDF. Click on the "New..." button again to create another tool.

KileSage8I've called it Compile Sage. Click "OK" KileSage9Go to the advanced tab and for "Type", select "Run Sequence of Tools" from the drop down menu.

KileSage10In the General tab, you can choose from existing tools, and combine these in a sequence. Click on Archive to select the tools to chain together.KileSage12Select PDFLaTeX as the tool and then click on "Add" to add it to the list.

KileSage13Select SAGE for the next tool, Add to add it to the sequence, select PDFLaTeX, add it and then finally select ViewPDF: KileSage14After clicking on OK you're done. Go to the toolbar of Kile, click on "Build" followed by "Other" and right click on "CompileSage". You'll be given the option to add it to the toolbar or create a keyboard shortcut. Select toolbar and you'll have a button that says "CompileSage". Clicking on that button runs pdflatex, compiles the resulting sage file, runs pdflatex again and opens up the resulting PDF. Provided you've got the Sage code working, chaining the commands together will save you a lot of time over doing the process manually.

Leave a Reply

Your email address will not be published. Required fields are marked *

AlphaOmega Captcha Classica  –  Enter Security Code