Ask Your Question

TexShop sage.engine can't tell if running Sage is necessary

asked 2016-11-30 23:06:03 -0600

markus gravatar image

updated 2016-12-01 15:23:41 -0600

I have switched from version 2012/01/16 v2.3.3-69dcb0eb93de to version 2015/08/26 v3.0-92d9f7a. When I compile a tex file using sage.engine it can't determine whether sage needs to run or not. I've narrowed this down to the if statement in sage.engine

# do we need to run Sage?
if [ -f "$soutname" ]
    new_sum=$(egrep -v '^( _st_.goboom|print .SageT)' "$sagename" | md5)
    old_sum=$(egrep -o ^%[0-9a-f]{32}% "$soutname" | cut -b 2-33)
    if [ "$new_sum" != "$old_sum" ]
    # no .sout file, so run Sage

I think the first egrep call should also eliminate lines containing current_tex_line. I've tried

new_sum=$(egrep -v '^( _st_.goboom|print .SageT)' "$sagename" | egrep -v '^( _st_.current_tex_line)' | md5)

but to no avail.

Any ideas would be much appreciated. Thanks.

Here is an example: the test.tex file

% !TEX TS-program = sage

produces among other things a sagetex.sout file that contains

% This file was *autogenerated* from test.sagetex.sage with
 % version 2015/08/26 v3.0-92d9f7a
%b22d43e1240df548df8cf6749b32284b% md5sum of corresponding .sage file (minus "goboom", "current_tex_line", and pause/unpause lines)

The sage.engine if statement should compare the md5 value of sagetex.sage minus a few lines to the md5sum in sagetex.sout.

edit retag flag offensive close merge delete


I feel like this might have happened to me before, but certainly not consistently enough to have noticed it for sure. Can you give a minimal example of a file and a change in it that (reproducibly) doesn't trigger the recompile? That is what we'd really need to think about this properly.

kcrisman gravatar imagekcrisman ( 2016-12-01 07:54:39 -0600 )edit

Thanks for your response. I've added an example.

markus gravatar imagemarkus ( 2016-12-01 15:25:00 -0600 )edit

Glad you figured out your problem, but I still don't see what the line you would change would be that in the current SageTeX causes it not to recompile with Sage.

kcrisman gravatar imagekcrisman ( 2016-12-01 22:16:15 -0600 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2016-12-01 21:44:19 -0600

markus gravatar image

I've figured it out. Replacing the new_sum line sage.engine by

new_sum=$(egrep -v '^( _st_.goboom|print .SageT)' "$sagename" | egrep -v '(_st_.current_tex_line)' | md5)

does the trick.

edit flag offensive delete link more


If you think this is really a bug, I highly recommend emailing Richard Koch, the TeXShop author ( to report this. Apparently he is very responsive, or so the frequent updating would suggest.

kcrisman gravatar imagekcrisman ( 2016-12-01 22:22:11 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2016-11-30 23:06:03 -0600

Seen: 50 times

Last updated: Dec 01 '16