Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sage 5.5 was just released. It is a Linux native, is there a way to use it within windows with minimal constraints?

share|improve this question
add comment

1 Answer 1

After experimenting, I suggest the following method. It is based on MikTex 2.9, TeXnicCenter, VMWare player (this one is free for home use), Linux Mint 14 with Cinnamon and of course Sage 5.5. It should be similar if you use VirtualBox. The goal was to use windows as most as possible and linux as little as possible, there is no need here to install TexLive in the virtual machine and to coordinate it with MikTeX.

The big picture is this one, it should be enough for a windows geek, it is followed by a more detailed explanantion.

INSTALLATION

  1. Install a virtualization software (VMWare, Virtual Box, Windows Virtual PC)
  2. Install a Debian Linux distribution (Mint 14 Cinnamon recommended as closest to the Windows look and feel)
  3. Share your TeX document directory between the host and the guest operating system with R/W rights
  4. Download and expand the latest sage package (Ubuntu 32 bit)
  5. "Install" sage in any user directory, sage being "portable", in windows parlance it is just a move of the directory
  6. Transfer the sage tex directory to the host operating system
  7. Make sage "known" to MikTeX, like any other new style or package

UTILIZATION

  1. "Miktexify" your *.tex file using the sagetex package with pdflatex,
  2. this generate a new *.sagetex.sage in your TeX directory and some warnings
  3. Open the guest operating system and start sage in a terminal
  4. Using a DOS, Linux command cd (change directory) at the sage prompt place the sage program in the shared Host/Guest Tex directory
  5. load (execute) sage your *.sagetex.sage file,
  6. this will generate two new files *.sagetex.scmd and *.sagetex.sout in your tx directory
  7. "Miktexify" your *.tex file again, the result of the sage computation will be written to your pdf output.

The result is just great, really worth the installation effort, it will improve the quality of your document avoiding typos in long expressions.

In the following modus operandi, the places where the Sage documentation is insufficient or not up to date are more detailed

  1. Install VMWare player from https://my.vmware.com/web/vmware/free#desktop_end_user_computing/vmware_player/5_0
  2. Install your favorite Linux distro (but if you read this, you are obviously not a Linux fan so use Linux Mint 14 with Cinnamon, the closest to windows so far). http://www.linuxmint.com/edition.php?id=117
  3. Install VMWare tools

Let suppose that your windows working Tex directory is C:\Documents\Maths and your name is usrx

Within VMWare Virtual Machine Settings, tab Options Enable Shared Folders, always enable, uncheck the read only case in properties (the default is RW so it should not be necessary). In the Hardware tab for network adapter use NAT.

Download the package "sage-5.5-linux-32bit-ubuntu_12.04.1_lts-i86-Linux.tar.lzma" from http://www.sagemath.org/download.html and expand it (as a you would do in windows..) in your user directory /home/usrx, rename the directory to sage55 to make it short.

You now have sage installed in the directory /home/usrx/sage55, test it by double clicking the sage icon, choosing run in a terminal (let the directory update run its course)

When you get the sage: prompt, test it with your favorite instruction, 2+2 may be, if you get 4 you are good to go.

enter image description here

Now, using Nemo, (here Windows users can read Explorer, the file icon at the bottom of the screen) open the directories /home/usrx/sage55/local/share/texmf where you get a directory tex, right click and copy it.

From the same nemo double click File System then the icon mnt (mount) and then hgfs. If everything went OK, you should find there your windows directory, Maths shared between the host (Windows) and the guest (Mint 14).

In this directory you paste the tex directory copied from /home/usrx/sage55/local/share/texmf

Now, we get back to windows but do not close the virtual machine, neither the sage terminal, you will use it for sagetex.

Using Administrator rights copy again this directory to your MikTeX installation with your other particular styles for example (I use one called modified C:\Program Files\MiKTeX 2.9\tex\latex\modified , e.g.) so that you now have C:\Program Files\MiKTeX 2.9\tex\latex\modified\tex).

Update MikTex from the program menu, with the Maintenance (Admin) Setting(admin) Refresh FNDB button as usual.

enter image description here

Now we can try to use sagetex.

From TeXnicCenter, create a sample tex file, such as this one

\documentclass{article}
\usepackage{sagetex}
\begin{document}
 Factoring $x^{12}-y^{12}$.
\
  With Sage, for the rationals, we find
   \begin{sageblock}
   L.<x,y>=LaurentPolynomialRing(QQ)
   f=x^(12)-y^(12)
   \end{sageblock}
  \[\sage{f.factor()}\]
In the real domain we find 
\[x^{12}-y^{12}=(x+y)(x-y)\left(x^2+y^2\right)\left(x^2+y^2+xy\right)\left(x^2+y^2-   xy\right)\left(x^2+x y \sqrt{3}+y^2\right)\left(x^2-x y \sqrt{3}+y^2\right).\]
\end{document}

call it SageX.tex, e.g.

Build and view your file once. You will have warnings about unreferenced sage items

enter image description here

and in your /mnt/hgfs/Maths directory, you will find a new file called SageX.sagetex.sage (NOT SageX.sage). The pdf file will have ?? where the answer to the factorization should be.

enter image description here

Go back to the virtual machine, to the sage terminal and sage prompt (sage:) There you need to type a linux instruction followed by return, (Here the sage manual says that a linux instruction should be typed !cd but this does not work) enter image description here

sage: cd /mnt/hgfs/Maths 

(change to the share windowslinux directory), you should see this answer /mnt/hgfs/Maths Now type the instruction sage: load SageX.sagetex.sage If all went well you will get the answer

sage: load SageX.sagetex.sage
Processing Sage code for SageX.tex...
Code block begin...end
Inline formula 0
Sage processing complete. Run LaTeX on SageX.tex again.

Back to Windows. In C:\Documents\Maths, you have two new files SageX.sagetex.scmd and SageX.sagetex.sout. Run TeXnicCenter again, you should have no more warnings and the factorization of the polynomial in the rationals, computed by sage, will have replaced the ??.

enter image description here

Note that as long as you do not modify the sage instruction, you don't need to run sage again, you can modify your text or add new LaTeX code within windows as long as you don't add (or modify) new sage code (or as long as you delete the three *.sage, *.scmd and *.sout files).

Sagetex is a great product so my hope is that some windows users will try the process and be convinced by the product (and also help in improving this text)...

share|improve this answer
    
sagetex can be installed with the package manager in MiKTeX. I cannot judge, though, whether this is the recent version; otherwise regarding “transfer sage directory and make sage known to MiKTeX” I want to point to Create a local texmf tree in MiKTeX. And: For Sage there exists a Windows binary, what actually is a VirtualBox image, as written by you. –  Speravir Mar 1 '13 at 1:52
    
I would like to add that this wasn't sufficient for me to work. Sage could not compile plots. Running " sudo apt-get install python-numpy " in the terminal got me what was missing and now it works. But thanks for the step by step tutorial. –  Jean-Sébastien Feb 6 at 22:57
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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