Ask Your Question
0

Can sagetex generate tex files?

asked 4 years ago

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.

Preview: (hide)

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 ( 4 years ago )

2 Answers

Sort by » oldest newest most voted
0

answered 4 years ago

Sébastien gravatar image

updated 4 years ago

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.

Preview: (hide)
link
0

answered 4 years ago

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/

Preview: (hide)
link

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: 4 years ago

Seen: 355 times

Last updated: Sep 03 '20