3

I recently installed SageMath on my linux and tried SageTex on Texmaker as follows:

run pdflatex on Texmaker, run load("example.sagetex.sage") from the build folder with Sage, and run pdflatex on Texmaker again.

The only catch is that I have to move the sage-plot-for-example.tex folder (generated plot figures by Sage) in the same directory/folder of the example.tex file. Otherwise, error occurs.

This would not be needed if the option for use a build subdirectory for output files is not checked in the Texmaker configuration. But I like the subdirectory as I feel the files are more neatly arranged. For similar problems with Bib(la)tex and Makeindex, this can be resolved by replacing the directory options bibtex %.aux with bibtex build\%.aux and makeindex %.idx with makeindex build\%.idx in the Texmaker configuration under 'Commands'.

I was wondering if there is a way to configure this in texmaker?

Any help or suggestion? Thanks!

Edits Sagetex works just fine with use a build subdirectory for output files option if the sage codes have nothing to do with figures.

  • 1
    @AndreC, Thanks for the edit! – mark haokip Jul 18 '20 at 19:11
  • Did you try the usual instructions instead of using load() ? – Dima Pasechnik Jul 21 '20 at 02:36
  • @DimaPasechnik, sage: sage example.sagetex.sage returns the error ---
    File "", line 1 sage example.sagetex.sage ^ SyntaxError: invalid syntax. So, I had to use the one mentioned here https://tex.stackexchange.com/questions/251459/strange-result-when-trying-to-use-sagetex instead.
    – mark haokip Jul 21 '20 at 18:10
  • Could you please post the first few lines of example.sagetex.sage - and the full error message, if possible? – Dima Pasechnik Jul 22 '20 at 06:21
  • @DimaPasechnik, these are the first few lines ... `## -- encoding: utf-8 --

    This file (example.sagetex.sage) was autogenerated from example.tex with sagetex.sty version 2019/11/14 v3.4.

    import sagetex st = sagetex.SageTeXProcessor('example', version='2019/11/14 v3.4', version_check=True) try: st.current_tex_line = 35 st.inline(0, latex(2+2)) except: st.goboom(35)`

    – mark haokip Jul 22 '20 at 15:43
  • and the error -- sage: sage example.sagetex.sage File "<ipython-input-1-555918340150>", line 1 sage example.sagetex.sage ^ SyntaxError: invalid syntax – mark haokip Jul 22 '20 at 15:44
  • what Sage version are you using? – Dima Pasechnik Jul 23 '20 at 16:15
  • 9.0 has a very old version of Sagetex, that is, its Python part might not match Sagetex 3.4 that you are using. – Dima Pasechnik Jul 25 '20 at 08:39
  • You probably have incompatible TeX and Python parts of sagtex - only one of them is v3.4, as printed in your error message. Where/how have you got the TeX part?

    (I don't know anything about texmaker, sorry - feel free to tell the details)

    – Dima Pasechnik Jul 26 '20 at 11:05
  • I installed texlive (various versions and not texlive 2020). Do you think an installation of the latest texlive will solve it? – mark haokip Jul 26 '20 at 11:06
  • I gather installing texlive might not install the Python part of sagetx correctly – Dima Pasechnik Jul 26 '20 at 11:08
  • do you think miktex would work better with it? – mark haokip Jul 26 '20 at 11:08
  • no, it has nothing to do with texlive/miktex, per se. SageTeX has TeX style files and Python files, they must play together to work right.

    By the way, is your Sage Python 2 or Python 3? (cf. the 2nd line of the Sage banner)

    – Dima Pasechnik Jul 26 '20 at 11:12
  • 3.8.2, to be precise. – mark haokip Jul 26 '20 at 11:13
  • well, we're officially supporting only Python 3.7 in Sage, not 3.8... Is this provided by a Linux distro, such as arch? – Dima Pasechnik Jul 26 '20 at 11:16
  • yes, linux mint 20. – mark haokip Jul 26 '20 at 11:17
  • what you see if you start sage, and then do
    sage: import sagetex
    sage: sagetex.pyversion
    
    – Dima Pasechnik Jul 26 '20 at 11:38
  • sorry, sage: is the prompt. The text to type is import sagetex sagetex.pyversion – Dima Pasechnik Jul 26 '20 at 11:57
  • '2019/11/14 v3.4' – mark haokip Jul 26 '20 at 12:04
  • OK, so Python files of sagetex are up to date. How about TeX? In the directory where you run latex on example.tex, could you run grep "Package: sagetex" example.log and post the output (this should tell the TeX files version) – Dima Pasechnik Jul 26 '20 at 12:28
  • the latter should be run at the shell prompt. By the way, the same applies to your attempt to run sage on example.sagetex.sage. The shell command to run is sage example.sagetex.sage.

    (Trying this at sage: ptompt will produce the error you showed above - apologies for mis-reading - I was a.f.k. then)

    – Dima Pasechnik Jul 26 '20 at 12:31
  • shell, a.k.a. bash, a.k.a. terminal, a.k.a. shell prompt, a.k.a. bash prompt – Dima Pasechnik Jul 26 '20 at 12:33
  • $ grep "Package: sagetex" example.log returns Package: sagetex 2019/11/14 v3.4 embedding Sage into LaTeX documents – mark haokip Jul 26 '20 at 12:41
  • A view of the first few lines of example.log is as follows: This is pdfTeX, Version 3.14159265-2.6-1.40.20 (TeX Live 2019/Debian) (preloaded format=pdflatex 2020.7.17) 21 JUL 2020 23:50 entering extended mode restricted \write18 enabled. %&-line parsing enabled. **example.tex (./example.tex LaTeX2e <2020-02-02> patch level 2 L3 programming layer <2020-02-14> – mark haokip Jul 26 '20 at 12:43
  • do you get correct results if you use shell prompt to run sage example.sagetex.sage – Dima Pasechnik Jul 26 '20 at 13:55
  • yes, I got it now. previously, i used to run sage example.sagetex.sage on sage, which was the reason for the problem, perhaps on sage it should be example.sagetex.sage. @DimaPasechnik Thanks! But I am still stuck with having to move the sage output folder (for sage generated figures) in the same directory with my example.tex file. – mark haokip Jul 26 '20 at 14:55
  • do you have this problem if you do everything at the shell prompt? – Dima Pasechnik Jul 26 '20 at 17:58
  • 2
    no problem with that. like i mentioned in the post, use a build subdirectory for output files in texmaker option keeps the output files neat which i liked. without this option, everything works just fine. my problem is texmaker specific but thanks to you, some of my auxiliary problems have been resolved @DimaPasechnik. Ps I am new to linux as well as sagemath – mark haokip Jul 26 '20 at 19:05

0 Answers0