Ask Your Question
1

How to send a sagetex file to someone who doesn't use sage?

asked 2017-11-08 11:29:11 +0100

Deepak Sarma gravatar image

I have written an article in Sagemathcloud using the sagetex package. Now If I send it to a journal for publication or to any of my friends (who don't use sage), how can they run it? In a youtube video, I learned that in addition to the .tex file, I have to send the .sout file generated in SMC. I tried this method, but It didn't work. May be I'm missing something. Any suggestion will be appreciated. Thank you in advanced.

edit retag flag offensive close merge delete

Comments

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:

  • run LaTeX on your .tex file;
  • run Sage on the generated .sage file;
  • run LaTeX again.*

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...

dan_fulea gravatar imagedan_fulea ( 2017-11-08 12:09:25 +0100 )edit

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?

Deepak Sarma gravatar imageDeepak Sarma ( 2017-11-08 17:17:43 +0100 )edit

Since the information on the indeed used sagetex specific environments is missing, let me guess some of them that are used:

  • sageblock
  • sagesilent
  • sageverbatim
  • comment

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

\begin{verbatim}
# all that code
\end{verbatim}

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.

dan_fulea gravatar imagedan_fulea ( 2017-11-08 20:21:23 +0100 )edit

No, I don't have pictures in my articles, but have some graphs. I'll try to use your method. Thank you.

Deepak Sarma gravatar imageDeepak Sarma ( 2017-11-09 05:20:44 +0100 )edit

1 Answer

Sort by » oldest newest most voted
1

answered 2017-11-08 19:11:25 +0100

Emmanuel Charpentier gravatar image

updated 2017-11-08 23:28:19 +0100

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.pyscript, 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 sageblockand 'sageverbatim' environments into verbatim environments. Any sagesilentenvironment 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,

edit flag offensive delete link more

Comments

Sorry, I'm a new user of sage. Most of your terms are critical for me, I can't understand them all, I mean I have not understood what exactly you have suggested. But I'm trying to get you. Thank you

Deepak Sarma gravatar imageDeepak Sarma ( 2017-11-09 05:22:59 +0100 )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

Stats

Asked: 2017-11-08 11:29:11 +0100

Seen: 416 times

Last updated: Nov 08 '17