0

I am using latex and Sage (and sagetex) through TeXstudio and the terminal. I would like to have a build sequence that would do all the compilations with one signle button. Something like wha tis described here for TeXmaker, but with an additional improvent: Not all my latex documents have some sagetex inside. So having one single sequence would lead to errors if there is no .sage file, right? Ideally I would need to have two build sequences.

Also, I mus say that was not able to adapt the solution for TeXmaker, the menus look pretty different.

DC75
  • 31
  • 2
  • Is your question answered in Windows by this or in Linux by this? – DJP Apr 29 '20 at 01:45
  • Not exactly. These solutions are for TexMaker, and in all cases they provide a single build tool. Perhaps I don't need to have two separate tools? Do I? – DC75 Apr 29 '20 at 01:58
  • The post says "And here is the customising to run in ubiquitous TeXworks (TeX studio in detail below). ". The build tool is only needed for sagetex since it involves 3 runs: run latex, run Sage, run latex. If no sagetex, process as you normally do. – DJP Apr 29 '20 at 02:03
  • You are right! Sorry for that. However, I'm looking for a Linux solution, ideally something similar to the link in my original post. – DC75 Apr 29 '20 at 14:36

1 Answers1

0

Try this:

  1. First, go to the sagetex page of CTAN, here, download all the files to a directory and process as the CTAN page indicates (latex sagetex.ins and so on)
  2. Go to Configure tab for TeXStudio. Redefine the LuaLaTeX command so it will process Sage files as shown below: enter image description here

  3. At the bottom of the picture, see User Commands. Press + to create a command (I called it SAGE) which will chain several commands together enter image description here

  4. The commands to be created into a chain are shown below: enter image description here

To run the SAGE command, go to the "Tools" tab, select "user". You should see SAGE listed along with a keyboard shortcut. Now you're done. Create a document in that directory, run SAGE on it: enter image description here

DJP
  • 12,451
  • I created the sequence (xelatex + lualatex (as an alias for sage) + xelatex) and there's something not working. When I run it, the first xelatex pass goes right, but I get the error Erreur : impossible de lancer la commande sage "mydocument".sagetex.sage while when I run the exact same command from a terminal, and run xelatex once more, everything works fine. – DC75 Apr 29 '20 at 23:37
  • Your error message has quotation marks around mydocument. I don't think it should. The Luatex command has no quotes anywhere. Perhaps it's looking for "mydocument".sagetex.sage instead of mydocument.sagetex.sage. which is giving the error? The only other possibility I can think of is that you haven't followed the complete instructions of "Read Me" on the ctan sagetex link here. The chaining of commands, if it works from the terminal, should work. Check character by character to see it matches the pictures above. – DJP Apr 30 '20 at 00:16
  • Nope, that's not the problem. I also have Processus en cours : xelatex -synctex=1 -interaction=nonstopmode "mydocument".tex Processus terminé normalement More than that, when run sage "mydocument.sagetex.sage" (with quotation marks, it still works. Pretty strange.. – DC75 Apr 30 '20 at 00:38
  • I would suggest deleting all the mydocument files except for the .tex file, run it through TeXshop and see what files were created and what weren't. In particular, look at the sagetex.sout file and the log file for what happened when SAGE was run and any latex error messages. It could also be a communication problem between programs. See the section "Make SageTeX known to TeX" at the link here. Problems like this are why I use, and suggest others use, Cocalc. – DJP Apr 30 '20 at 01:00
  • Hello, I tried removing the files. The problem is really that TeXstudio is not able to launch sage. In my machine, sage and LaTeX work fine from the terminal.

    After the 1st run of xetex the .sagetex.sage file is there, but sage ***.sagetex.sage fails. Again, doing the exactly same thing from ther terminal gives the desired result. I also use Cocalc, but sometimes things goe faster using a local machine

    – DC75 May 03 '20 at 18:28
  • Since you know Sage isn't launching my final suggestion would be to try redefining another TeXShop command, such as your PS command, to launch Sage by telling it the path on your computer (something like usr/bin/sagemath ) and adding that to the chain of commands in step 4. Something like PDFlatex, PS (starts sage), LuaTex (runs sage), PDFLateX, PDFViewer. If that doesn't work, I'm out of ideas. – DJP May 03 '20 at 22:00