Ask Your Question

Sagetex : how to capture sageblock output for future use.

asked 2017-02-01 09:41:51 -0500

Emmanuel Charpentier gravatar image

updated 2017-02-01 10:45:36 -0500

[ This is more, I think, a \LaTeX question than a Sagemath question. But since it's centered on the use of Sagetex, it is probably the right place to ask... ]

I'd like to be able to do some (boring but necessary) computation without printing it, use its results, then, in an appendix, show the computation (without re-running it).

The obvious solution would be to run the computation in a sagesilent block, use its results, then later insert a sageverbatim environment with the same code :

## Boring computation
%% Lotsa discussion
## Boring computation again

The problem is that now, I have two copies of the same code, with no consistency guarantee (as illustrated in the example, BTW). I tried :

## boring computation
% Lotsadiscussion

But that doesn't work : The boring computation is still printed before the discussion and nothing is printed in the appendix. I'm not really surprised : the \LaTeX verbatim environments are full of such traps. And, no, using \protect is not enough.

Any idea ?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2017-02-01 13:27:16 -0500

kcrisman gravatar image

Hmm, I don't know much about verbatim or defining new variables. You are right about fragility, though, I get that kind of thing in beamer a lot. What I would do is this.

## Boring computation
## final result x = my_result
%% Lotsa discussion
The answer is $\sage{x}$.

Probably this should work?

edit flag offensive delete link more


This should work, yes. But it's not what I want to do.

The computation has to be available (for proof) but is in itself of little interest for readers. I want to be able to use its results in the main text, the add it to an appendix (think lemma enunciation vs demonstration, when the lemma is of weaker interest than the main theorem...).

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2017-02-02 01:04:09 -0500 )edit

I see what you mean now. Unsure as to solution, I don't use sageverbatim myself.

kcrisman gravatar imagekcrisman ( 2017-02-02 15:26:03 -0500 )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


Asked: 2017-02-01 09:41:51 -0500

Seen: 50 times

Last updated: Feb 01