4

The normal run of a tex-file which contains sagetex, say

\documentclass{report} 
\usepackage{sagetex} 
\begin{document} 
\sage{2^1234} 
\end{document}

is

pfdlatex example.tex
sage example.sagetex.sage
pfdlatex example.tex

For Linux this should run in exactly this form.
How to do it in the Windows command line?

cis
  • 8,073
  • 1
  • 16
  • 45

1 Answers1

5

Let

\documentclass{report} 
\usepackage{sagetex} 
\begin{document} 
\sage{2^1234} 
\end{document}

be named by example.tex

0) Run pdflatex example.tex for creating a sage-file

example.sagetex.sage

1) Find out where is your bash-executive bash.exe from your Sage-installation, it is something like

C:\Programme\SageMath8.9\runtime\bin\bash 

2) Find out where is your "sage-starting-file" sage [without extension] (which is getting startet by bash.exe, see later), it is something like

C:/Programme/SageMath8.9/runtime/opt/sagemath-8.9/sage 

3) Realize which is your current working folder, say

 C:\Users\ccc\Desktop\Test\SageTeX

4a) In the following sage-run you need to change Sage's home directory to your current working folder from No. 3; the sage-command is

os.chdir('C:\Users\ccc\Desktop\Test\SageTeX')

BTW: You can check your Sage-Home in a Sage-Shell by typing in os.getcwd()

4b) And you have to run your sage-file; the sage-command is

load('example.sagetex.sage')

Alltogether in the Windows-cmd:

C:\Programme\SageMath8.9\runtime\bin\bash 
  -l C:/Programme/SageMath8.9/runtime/opt/sagemath-8.9/sage 
       -c "os.chdir('C:\Users\ccc\Desktop\Test\SageTeX');      
                load('example.sagetex.sage')"

Use this without linebreaks!

5) If all works, Sage will say to you: Run

pdflatex example.tex

again. After that you will get your sageteXed example.pdf.

cis
  • 8,073
  • 1
  • 16
  • 45
  • Due to that we need a shortcut with @PauloCereda 's arara. Be wellcome here: https://tex.stackexchange.com/questions/520683/arara-sage-a-sagemath-rule-for-arara – cis Dec 20 '19 at 15:36