Fasten SageTex to LyX under Windows
Prelude
Recently, while reviewing the blog LaTeX, came across an interesting article Mathematical calculations and graphics in LyX using Sage. In the head immediately thought of the type "there is Finally a reason
A little crestfallen, I decided to try the option offered on download page — use virtual machine.
Despite assurances that "The current VirtualBox Image provides you with an encapsulated and solid tested system and contains everything and needs nearly no configuration.", it was a perfect image it is not clear how to force LyX to communicate with Sage installed somewhere, far away, on the virtual machine. But out there™, and found, oddly enough, the documentation for SageTex is to use a running Sage in virtual reality through the web API.
Recipe
Training
First of all, LyX will need some LaTeX distribution. Not going into detail, my only comment is that I used MikTeX. How to install and configure, well described here.
Now, of course, download and install LyX. Download also virtual machine image with Sage. For the proposed use of the VirtualBox or free VMWare Player.
The script performing communication with Sage written in Python, which is download and install.
The script can be loaded, for example, otsuda.
Action
-
the
- will Create somewhere on the screw a folder, which will reset all the essential image of the Sage and remote-sagetex.py and also add this folder to the PATH environment variable of the system (that's where LyX will look for the script) the
- Processing Sage code inside LaTeX document takes place in three stages — after the first pass latex.exe from the source .tex file generates a file with the extension .sage. This file is fed to Sage, which will give us the file .sout containing directly the calculation results. In the second run latex.exe will pick up these values and insert them into the document.
- Now we need to teach LyX to use our script to generate a PDF. To do this, open LyX, go to Tools→options...→file Handling→Converters→ and add a new handler LaTex - > PDF(ps2pdf), something like this
Why ps2pdf and not pdflatex? For reasons beyond me, the graphics obtained with the help of Sage, refuse to appear in the resultant PDF in any form. If anyone knows what the problem is, I would be grateful for a solution.
unfortunately, LyX has no idea about Sage. Well, teach him. Create all in the same folder as the bat file. Let's call it ps2pdf_sage.bat and give it the following content:
::first passage
latex %~n1.tex
::the processed file .sage obtained after the first pass.
::the server settings in the Sage Notebook by default
remote-sagetex.py -s localhost:8000 -u admin -p sage %~n1.sage
::second - pass model in document commands in Sage results in LaTeX
latex %~n1.tex
::generated PDF
dvips %~n1.dvi
ps2pdf %~n1.ps
the
Everything is ready. It remains only to add \usepackage{sagetex}
in the preamble of the document (MikTex if needed download this package from the repository).
A simple example: source and PDF.
P. S. the Topic was written by abrollcontainer ZimM and published at his request.
Комментарии
Отправить комментарий