1 | initial version |
The sagetex.pdf
TeXdoc file for SageTeX recommends (§ 4.7.1) to set up a set of file on cloud.sagemath.org
(now cocalc). That doesn't seem very reasonable unless your correspondent is able to use Sage...
However, §4.7.2 of the same document points to the makestatic.py
script, which _should_ get you a \LaTeX file producing the same output as your original file. Parphrased from this doc :
There is another option, and that is to use the makestatic.py script included with SageTEX. This script has been unmaintained for some time and likely won’t work. If you want or need to use it and run into trouble, email the sage-support group and let us know.
Use of the script is quite simple. Copy it and
sagetexparse.py
to the directory with your document, and run
`python makestatic.py inputfile [outputfile]`
where
inputfile
is your document. (You can also set the executable bit of makestatic.py and use ./makestatic.py.) This script needs thepyparsing
module to be installed. You may optionally specifyoutputfile
; if you do so, the results will be written to that file. If the file exists, it won’t be overwritten unless you also specify the -o switch.You will need to run this after you’ve compiled your document and run Sage on the .sage file. The script reads in the
.sout
file and replaces all the calls to\sage
and\sageplot
with their plain\LaTeX
equivalent, and turns thesageblock
and 'sageverbatim' environments intoverbatim
environments. Anysagesilent
environment is turned into acomment
environment. Anysagecommandline
environment is turned into alstlisting
environment, typesetting the relevant part of the.scmd
file. The resulting document should compile to something identical, or very nearly so, to the original file.One large limitation of this script is that it can’t change anything while SageTeX is paused, since Sage doesn’t compute anything for such parts of your document. It also doesn’t check to see if
pause
andunpause
commands are inside comments orverbatim
environments. If you’re going to usemakestatic.py
, just remove allpause
/unpause
statements.The parsing that makestatic.py does is pretty good, but not perfect. Right now it doesn’t support having a comma-separated list of packages, so you can’t have
\usepackage{sagetex,foo}
. You need to have just \usepackage{sagetex}. (Along with package options; those are handled correctly.) If you find other parsing errors, please let me know.
Caveat : I have never used this script myself (yet). But it sounds like a possible solution (possibly modulo some script fixes...).
Could you let us know :
If you tried this solution,
if it worked,
if it needed fixes, and if so, which ones ?
possibly by a post to sage-support
or sage-devel
?
HTH,
2 | No.2 Revision |
EDIT : I checked makestatic.py, and it turns out that this script currently does not work. I keep the rest of my answer here as a hint to people interested in fixing it.
The sagetex.pdf
TeXdoc file for SageTeX recommends (§ 4.7.1) to set up a set of file on cloud.sagemath.org
(now cocalc). That doesn't seem very reasonable unless your correspondent is able to use Sage...
However, §4.7.2 of the same document points to the makestatic.py
script, which _should_ get you a \LaTeX file producing the same output as your original file. Parphrased from this doc :
There is another option, and that is to use the makestatic.py script included with SageTEX. This script has been unmaintained for some time and likely won’t work. If you want or need to use it and run into trouble, email the sage-support group and let us know.
Use of the script is quite simple. Copy it and
sagetexparse.py
to the directory with your document, and run
`python makestatic.py inputfile [outputfile]`
where
inputfile
is your document. (You can also set the executable bit of makestatic.py and use ./makestatic.py.) This script needs thepyparsing
module to be installed. You may optionally specifyoutputfile
; if you do so, the results will be written to that file. If the file exists, it won’t be overwritten unless you also specify the -o switch.You will need to run this after you’ve compiled your document and run Sage on the .sage file. The script reads in the
.sout
file and replaces all the calls to\sage
and\sageplot
with their plain\LaTeX
equivalent, and turns thesageblock
and 'sageverbatim' environments intoverbatim
environments. Anysagesilent
environment is turned into acomment
environment. Anysagecommandline
environment is turned into alstlisting
environment, typesetting the relevant part of the.scmd
file. The resulting document should compile to something identical, or very nearly so, to the original file.One large limitation of this script is that it can’t change anything while SageTeX is paused, since Sage doesn’t compute anything for such parts of your document. It also doesn’t check to see if
pause
andunpause
commands are inside comments orverbatim
environments. If you’re going to usemakestatic.py
, just remove allpause
/unpause
statements.The parsing that makestatic.py does is pretty good, but not perfect. Right now it doesn’t support having a comma-separated list of packages, so you can’t have
\usepackage{sagetex,foo}
. You need to have just \usepackage{sagetex}. (Along with package options; those are handled correctly.) If you find other parsing errors, please let me know.
Caveat : I have never used this script myself (yet). But it sounds like a possible solution (possibly modulo some script fixes...).
Could you let us know :
If you tried this solution,
if it worked,
if it needed fixes, and if so, which ones ?
possibly by a post to sage-support
or sage-devel
?
HTH,