ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 09 Jan 2020 22:24:25 +0100Introduction: A shortcut for the compiling of SageTeX-files with ararahttps://ask.sagemath.org/question/49378/introduction-a-shortcut-for-the-compiling-of-sagetex-files-with-arara/*Note: This is a meta-post, so no answers are needed. I will answer it by myself.*
My dearest SageTeXers, Sagers, arara-users and Pythoners as well!
The normal way to compile a file `example.tex` which contains SageTeX is
`pdflatex example.tex` <br>
`sage example.sagetex.sage`<br>
`pdflatex example.tex`
So the initial question is: How to make a shortcut for this?Sun, 05 Jan 2020 18:36:10 +0100https://ask.sagemath.org/question/49378/introduction-a-shortcut-for-the-compiling-of-sagetex-files-with-arara/Answer by geroyx for <p><em>Note: This is a meta-post, so no answers are needed. I will answer it by myself.</em></p>
<p>My dearest SageTeXers, Sagers, arara-users and Pythoners as well!</p>
<p>The normal way to compile a file <code>example.tex</code> which contains SageTeX is</p>
<p><code>pdflatex example.tex</code> <br>
<code>sage example.sagetex.sage</code><br>
<code>pdflatex example.tex</code></p>
<p>So the initial question is: How to make a shortcut for this?</p>
https://ask.sagemath.org/question/49378/introduction-a-shortcut-for-the-compiling-of-sagetex-files-with-arara/?answer=49379#post-id-49379If you use [arara](https://www.ctan.org/pkg/arara), known as "The cool TeX-automatisation Tool", written by @PauloCereda, you can set compilation instructions into your tex-document, i.e. <br>
`% arara: pdflatex` <br>
`% arara: biber` <br>
`.....` <br>
and then only one run `arara example.tex` is needed. <br>
In TeXLive arara is installed by default. You can also integrate arara into your TeX editor.
There is no arara-rule for Sage in the main set of arara-rules, but it has been written: <br>
See the original post [arara: sage - A Sage(math)-rule for arara](https://tex.stackexchange.com/a/521688/46023)
It is `sagetex.yaml`, which works for [Windows-users](https://tex.stackexchange.com/a/521197/46023) and for Linux-users:
!config
# SageTeX-Rule for arara.
#
# Dear Windows-users, please check the paths
# pathToBashExecutive and pathToSageStartfile
# due to your Sage-installation!
#
identifier: sagetex
name: SageTeX
authors:
- TeXnician (Author)
- cis (Idea)
arguments: []
commands:
- name: A SageTeX Rule for arara
command: >
@{
pathToBashExecutive = "C:\\Programme\\SageMath8.9\\runtime\\bin\\bash";
pathToSageStartfile = "C:/Programme/SageMath8.9/runtime/opt/sagemath-8.9/sage";
pathOfCurrentWorkingFolder = currentFile().getParent();
theWindowsCommand = getCommand(pathToBashExecutive, "-l", pathToSageStartfile, "-c", "os.chdir('" + pathOfCurrentWorkingFolder + "'); load('" + getBasename(currentFile()) + ".sagetex.sage')");
return isWindows(theWindowsCommand, getCommand("sage", getBasename(file) + ".sagetex.sage"));
}
Let's test an `example.tex` <br>
% arara: pdflatex
% arara: sagetex
% arara: pdflatex
\documentclass{report}
\usepackage{sagetex}
\begin{document}
\sage{2^1234}
\end{document}Sun, 05 Jan 2020 18:36:36 +0100https://ask.sagemath.org/question/49378/introduction-a-shortcut-for-the-compiling-of-sagetex-files-with-arara/?answer=49379#post-id-49379Answer by Sébastien for <p><em>Note: This is a meta-post, so no answers are needed. I will answer it by myself.</em></p>
<p>My dearest SageTeXers, Sagers, arara-users and Pythoners as well!</p>
<p>The normal way to compile a file <code>example.tex</code> which contains SageTeX is</p>
<p><code>pdflatex example.tex</code> <br>
<code>sage example.sagetex.sage</code><br>
<code>pdflatex example.tex</code></p>
<p>So the initial question is: How to make a shortcut for this?</p>
https://ask.sagemath.org/question/49378/introduction-a-shortcut-for-the-compiling-of-sagetex-files-with-arara/?answer=49484#post-id-49484One may also write
default:
pdflatex example.tex
sage:
pdflatex example.tex
sage example.sagetex.sage
pdflatex example.tex
in a file called `makefile` in the same directory and then run `make` or `make sage`. (I think the four spaces must really be tabulations)Thu, 09 Jan 2020 22:24:25 +0100https://ask.sagemath.org/question/49378/introduction-a-shortcut-for-the-compiling-of-sagetex-files-with-arara/?answer=49484#post-id-49484