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 the pyparsing
module to be installed. You may optionally specify outputfile
; 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 the sageblock
and 'sageverbatim' environments into verbatim
environments. Any sagesilent
environment is turned into a comment
environment. Any sagecommandline
environment is turned into a lstlisting
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
and unpause
commands are inside comments or verbatim
environments. If you’re going to use makestatic.py
, just remove all pause
/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,
The pdf file, the tex file, and the changed tex file with only plain verbatim blocks would be enough for the friends. For a publication, if so restricted, it is a little more work to produce sage code output and figures explicitly and use them in tex. As explained in
http://doc.sagemath.org/html/en/tutorial/sagetex.html
all data is available. Pictures are in a folder, further tex input is also given. Citing that place:
*In general, the mantra is:
And now it explains very clear...
The warning message told you to run Sage on st_example.sagetex.sage, so take its advice and do that. It will tell you to run LaTeX on...
What do you mean by " changed tex file with only plain verbatim blocks"? Which file is this? Besides I have gone through the sage documentation, but didn't get the middle statement (run Sage on the generated .sage file), how to run the .sage file in sage? What exactly should I do?
Since the information on the indeed used sagetex specific environments is missing, let me guess some of them that are used:
Some of them are relevant for the publication, for the printed text, some not. Change the relevant ones into "plain verbatim environments", i.e. use
Are pictures involved in the article? If yes, they should have been generated in some directory, so can be explicitly included in $\LaTeX$. The publisher will usually accept such a file. (eps file maybe.) Generally, it is best to position them explicitly, so that each pic fits in the page and in the context.
No, I don't have pictures in my articles, but have some graphs. I'll try to use your method. Thank you.