Ask Your Question
0

Can sagetex generate tex files?

asked 2020-08-31 08:58:58 +0100

done_with_fish gravatar image

I'm writing a latex document that will eventually need to be compiled on a machine that does not have sage on it. However, right now I'm using sagetex to write this document. I'm curious if it is somehow possible to generate a latex document with all of the \sage invocations replaced with the corresponding latex code.

edit retag flag offensive close merge delete

Comments

Yes, I did it just to convince myself it's possible. It's extremely tedious and I would discourage it. It involved creating a string that will be the contents of the tex file. So in the sagesilent part of the tex document I'd have: f = open(r"Answers.tex",'w') f.write(r"\documentclass[a4paper,addpoints,12point]{exam}") f.write("\n") f.write(r"\usepackage{amsmath, amsfonts, amssymb}") f.write("\n") f.write(r"\usepackage{xcolor}") and so on.

dazedANDconfused gravatar imagedazedANDconfused ( 2020-08-31 17:50:34 +0100 )edit

2 Answers

Sort by » oldest newest most voted
0

answered 2020-08-31 11:07:40 +0100

Sébastien gravatar image

updated 2020-08-31 11:08:55 +0100

The latex document you need to provide is the same you use. You only need to also provide the .sout file (containing the results of the \sage invocations), the image folder generated by Sage if any and possibly the sagetex.sty file.

edit flag offensive delete link more
0

answered 2020-09-03 19:30:14 +0100

dantetante gravatar image

Since you didn't provide an example I'm not 100% sure what you want to do. Anyway you should have a look at jinja:

https://pypi.org/project/Jinja2/

edit flag offensive delete link more

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

Stats

Asked: 2020-08-31 08:58:58 +0100

Seen: 307 times

Last updated: Sep 03 '20