2

Asking by request to get a screenshot answer to figure out how to enable Sage in Texmaker as I apparently can't figure it out on my own.

Jason
  • 939

1 Answers1

2

First: Under "Options" select Configure Texmaker. enter image description here Running Sage isn't any of the options but we can redefine one of the commands so it calls Sage. I chose to redefine Metapost. Fill in the box with sage "%.sagetex.sage" as shown above.

Next: Click on Quickbuild. enter image description here Select "User" to define our own command and then select the "Wizard" button which will open up the window to select the commands. Select pdflatex from the list on the left, click the "Add" button and it will appear on the right hand side. Then select metapost from the left, click "Add" to get it on the right (this will activate Sage) and continue process to get pdflatex followed by PDF Viewer. Press OK to finalize the command. Now pressing the arrow to the left of Quickbuild will run Quickbuild resulting in all 4 steps: enter image description here

Jason
  • 939
DJP
  • 12,451
  • Tried it as listed here and got the oh-so-helpful error: "Error : could not start the command" It is possible in all the playing around trying to get latexmk to work earlier that I might have broken something there? – Jason Jun 24 '15 at 05:19
  • I doubt that. I think it's trying to start Sage but can't. I'm wondering about the latexmkrc file that you added the extra lines to. My system has more than one such file. I modified the one in the the asymptote file of the tex distribution as is discussed in more depth here. – DJP Jun 24 '15 at 05:31
  • I don't have a local/texlive file, but the one I edited is in the directory: /usr/share/texmf/tex/latex/asymptote/

    And I edited it to look like:

    `sub asy {return system("asy '$_[0]'");}
    
    add_cus_dep("asy","eps",0,"asy");
    
    add_cus_dep("asy","pdf",0,"asy");
    
    add_cus_dep("asy","tex",0,"asy");
    
    add_cus_dep('sage', 'sout', 0, 'makesout');
    
    $hash_calc_ignore_pattern{'sage'} = '^( _st_.goboom|print .SageT)';
    sub makesout {
    
        system("sage '$_[0].sage'");
    
    }`
    
    – Jason Jun 24 '15 at 05:33
  • That should be the one. I'm not sure what could be the problem. I'll need to think about this..... – DJP Jun 24 '15 at 05:41
  • Sorry, can't seem to get the formatting to display correctly here for that file, but I took the old content and added the lines to the bottom of the file.

    I also checked with a find command and that's the only asymptote folder with a latexmkrc file anywhere, so I assume that's the right one.

    – Jason Jun 24 '15 at 05:41
  • I think you've done all that correctly and in the right place. It might be a communication issue like is mentioned here. – DJP Jun 24 '15 at 05:42
  • For diagnostic purposes I tried running just latexmk with the user command and it ran fine (minus the whole not handling sage stuff and getting annoyed at me).

    I then tried the same thing with metapost and ran that by itself. It threw up a ton more sage errors, but otherwise completed.

    Then I made a user command of latexmk then metapost and I got the "Error: could not start the command."

    – Jason Jun 24 '15 at 05:46
  • Well, I've pretty much given up getting Texmaker to actually work, but if I use pdflatex then bring up a terminal in the folder with the file of interest and type sage (filename).sagetex.sage it does actually compile, so it's a pain but I guess that's what I'm going with until I decide to drop another 20+ hours trying to figure this out.

    For whatever it's worth this is on a chromebook using trusty chroot, and I did a complete powerwash and fresh reinstall, still with no luck.

    – Jason Jun 24 '15 at 20:38
  • Ok, I figured out how to make it work, so I'll mark this as answered as this guide was about 99% correct, it was a small thing which I added as an edit on the original answer. Details are here"

    First, I needed to use pdflatex instead of latexmk for that step, so quick build is "PDFlatex -> metapost -> PDFlatex -> PDFviewer"

    Second, I needed " around the sage step, so it should read

    sage "%.sagetex.sage"

    Since I had a space in my file name without realizing it, which is why it was throwing an error.

    – Jason Jun 28 '15 at 21:00
  • Glad to hear you got it to work--but instructions I gave above (without quotes and using latexmk) work fine on my computer although sagetex was built for pdflatex. Odd. – DJP Jun 28 '15 at 22:42
  • As a stupid question I can't seem to find out how to modify the sage "%.sagetex.sage" line to account for compiling when you use the build directory option, is this a simple thing? If not then I don't care enough to make it work, it just bugs me having all the aux files floating around in my tex directory. – Jason Jun 29 '15 at 19:21
  • I have no idea. – DJP Jun 29 '15 at 19:51