On Tue, 01 Dec 2009 at 11:44AM -0800, Eric Drechsel wrote: > I'm experimenting with a homework workflow using sagetex. I'd like to > make efficient use of resources, which seems to be a (the?) major > deficiency with sagetex, especially with large documents. > > My initial thought was that by placing each problem in an included > file, I could have my build tool generate individual problem_x.sage > and problem_x.sout files only for problems with changes, and keep the > master tex file as a simple list of includes. I see now that that > can't work, however, at least with my limited knowledge of TeX tricks.
BTW, if your build tool is Latexmk [1] (which is included in TeXLive), I
wrote a "custom dependency rule" that makes it work intelligently with
SageTeX: put this into your .latexmkrc and it will run Sage as
necessary.
-----------------------------------------------------------------
# a SageTeX custom dependency rule for latexmk
add_cus_dep('sage', 'sout', 0, 'makesout');
sub makesout {
my $oldmd5 = "x";
my $currentmd5 = (split / /,
`egrep -v '^( _st_.goboom|print .SageT)' $_[0].sage | md5sum`)[0];
open(INFILE, "$_[0].sout");
while (<INFILE>) {
if (/^%([0-9a-f]{32})%/) {
$oldmd5 = $1;
}
}
if ($currentmd5 ne $oldmd5) {
system("sage $_[0].sage");
}
else {
print "md5sums for $_[0].sage and $_[0].sout match, not running Sage\n";
return 0;
}
}
-----------------------------------------------------------------
I'm very much not a Perl person, so that may not be the best way to do
it, but it seems to work well.
Dan
1. http://www.phys.psu.edu/~collins/software/latexmk-jcc/
--
--- Dan Drake
----- http://mathsci.kaist.ac.kr/~drake
-------
signature.asc
Description: Digital signature
