Good evening guys.

I've a big problem, as to simplify my school report, and don't do stupid mistakes while copy pasting some equations, I decided to try SageTex, and I've been struggling to make it works as an automated compilation. To be fair, I had to reinstall all because of an hard drive problem (MiKTeX console and texstudio 3.0.1, plus SageMath9.1, of course), and followed this guide, step by step. (post:sagetex in texstudio : define a new build tool )

This is my little experimental example.



Using Sage\TeX, one can use Sage to compute things and put them into
your \LaTeX{} document. For example, there are
$\sage{number_of_partitions(1269)}$ integer partitions of $1269$.
You don't need to compute the number yourself, or even cut and paste
it from somewhere.

Here's some Sage code:

    f(x) = exp(x) * sin(2*x)

The second derivative of $f$ is

  \frac{\mathrm{d}^{2}}{\mathrm{d}x^{2}} \sage{f(x)} =
  \sage{diff(f, x, 2)(x)}.

Here's a plot of $f$ from $-1$ to $1$:

\sageplot{plot(f, -1, 1)}


But as you might suspect it didn't worked. I go to tools>users and select the SAGE:SAGE profile and all I got is this PDF enter image description here

With this message,

Error: Impossible to run the command: sage "Sage-example".sagetex.sage

enter image description here

Moreover, I can't figure out how to navigate in my SageMath console (not Shell or Notebook) till my working directory and run my filename.sagetex.sage with the command sage, seem more like a UNIX environment in wich I can not find any of my actual folders. And when I try to run sage filename.sagetex.sage the windows prompt tell me it's an unrecognized comand.

Any idea in what could be the problem??


  • The easiest way to try sagetex is with a free Cocalc account. To change directories, try cd with a path to the directory containing your file; eg, cd '/home/MyDocuments'.
    – DJP
    Sep 27, 2020 at 20:57
  • Well ok, but I really would make it work on my machine. I started with ShareLatex, then I switched on my PC because for some assignement I couldn't plot all the graphs (it needed too much compiling time, for the free version) I needed. Now that I'm aware of this "issue" I'm a bit reluctant on going on a cloud based service .
    – Fr3d
    Sep 28, 2020 at 6:47
  • As expected..... > Free Trial (Day 4) – buy a license (starting at about $3/month) and apply it to this project. > Otherwise, expect VERY bad performance (e.g., 10 times slower!) and you can't install packages, clone from GitHub, or download datasets. So this sagetex example work perfectly, but I can't make the subfile package work properly. I have a cover I use for my weekly assignemts, and the I link my assignment with subfile. I do have to submit a notebook at the end of my course, with all my weekly assignements, so I have to link all of them as they are already done.
    – Fr3d
    Sep 28, 2020 at 7:41
  • Cocalc performance has dropped as late but for typical use, like your sample above, it shouldn't be a problem. I haven't worked with the subfile package but with a quick search on this site I found the post here which indicates that the subfiles package is supported for SMC, now Cocalc. They even link to a working example on github. If you aren't able to get that to work, contact Cocalc help.
    – DJP
    Sep 28, 2020 at 15:45


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.