AnswerBun.com

arara: sage - A Sage(math)-rule for arara

TeX - LaTeX Asked by cis on September 17, 2020

Completely edited!



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.

For Windows you have to compile the sage-part (2nd line) via

C:ProgrammeSageMath8.9runtimebinbash 
        -l C:/Programme/SageMath8.9/runtime/opt/sagemath-8.9/sage 
           -c "os.chdir('<My current working folder>');      
                    load('<my filename>.sagetex.sage')"

(without linebreaks), see here for details.

How to make a shortcut (for Windows and Linux) of this with arara?

My own try sagetex.yaml does not work 🙁

!config
identifier: sagetex
name: SageTeX
# Authors: 
# Version: 
# ===============================
# Info:  The Windows cmd-command is
# C:ProgrammeSageMath8.9runtimebinbash 
#    -l C:/Programme/SageMath8.9/runtime/opt/sagemath-8.9/sage 
#       -c "os.chdir('<My current working folder>');      
#                load('<my filename>.sagetex.sage')"
#For Windows =========================
arguments:
- identifier: PathToBashExecutive
  flag: >
     @{
        return C:ProgrammeSageMath8.9runtimebinbash
        }
- identifier: PathToSageStartfile
  flag: >
     @{
        return C:/Programme/SageMath8.9/runtime/opt/sagemath-8.9/sage
        }
- identifier: PathOfCurrentWorkingFolder
  flag: >
     @{
        return getBasename(toFile('getBasename(file).tex'));
        }
- identifier: TheWindowsCommand
  flag: >
     @{
        return 'PathToBashExecutive' -l 'PathToSageStartfile' -c "os.chdir('PathOfCurrentWorkingFolder'); load('getBasename(file).sagetex.sage')"
        }
# ===============================
commands:
- name: The application
  command: >
    @{
        return isWindows(TheWindowsCommand, sage getBasename(file).sagetex.sage);
       }

One Answer

In cooperation with the OP I did come up with the following:

!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"));
       }

arara 5.0

!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(reference) + ".sagetex.sage"));
       }

Correct answer by TeXnician on September 17, 2020

Add your own answers!

Related Questions

Problem with installing package metre

1  Asked on May 24, 2021 by rensemil

     

Adjusting logo in beamercolorbox

1  Asked on May 23, 2021 by bmb

 

How to evaluate an expression before printing it?

1  Asked on May 23, 2021 by shashank-sawant

 

How to get a longer nmid

1  Asked on May 23, 2021 by user217152

 

Undefined control sequence with hyperref

0  Asked on May 23, 2021 by ala-ali-hussein-yousef

     

CSV: How to write commas

1  Asked on May 23, 2021

   

Import EPS from OriginLab with ChemDraw structure into LaTeX

0  Asked on May 23, 2021 by martin-dagleish

     

How to enable Texstudio to add orders automaticlly

0  Asked on May 23, 2021 by buct-mec-1802-060

 

Ask a Question

Get help from others!

© 2022 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP, SolveDir