sagemath / sagetex

Embed code, results of computations, and plots from the Sage mathematics software suite (https://www.sagemath.org) into LaTeX documents. Source repository for https://pypi.org/project/sagetex/ and https://ctan.org/pkg/sagetex
https://ctan.org/pkg/sagetex
Other
58 stars 22 forks source link

sagecommandline echo all terminal output #52

Open dantetante opened 3 years ago

dantetante commented 3 years ago

I understand that >>Because of the way the environment is implemented, not everything is ...<< included because of the >>distinction between statements and expressions<<, as the sagetex docu tells me. I am not a good programmer and don't understand this. But I wanted to let you know that this is something that I would really appreciate, being able to automatically include the whole terminal output.

dimpase commented 3 years ago

The whole terminal output of a Sage command run at sage: prompt, or is it something else?

dimpase commented 2 years ago

Could you provide few more details: would you like to be able to include the output of a Sage command in a terminal session? Something else?

dantetante commented 2 years ago

Hi Dima,

sorry for not getting back to you earlier …

Could you provide few more details: would you like to be able to include the output of a Sage command in a terminal session? Something else?

If this were possible, we could avoid a lot of workaround work in a typesetting project I’m working on, i.e. the coming new release of the cryptool book (I wrote you from that twitter account). See https://www.cryptool.org/en/documentation/ctbook for the old version.

What also would be cool is if the same would be possible if a command is returning one or more pictures, i.e. having them put into the texfile via includegraphics, but this is not really important, though it would be cool ;-)

I attached two screenshots where you can see how we did it >>before<< and how we are doing it >>now<<. The before-version doesn’t need the print-statements and looks better for people who want to read, follow and understand the code, the now-version has the advantage that it’s ready to run, so we can offer downloads of the examples. We wanted to avoid having to maintain two sagecode versions, one runnable and another for the tex listings;

we could not use sagetex because of this terminal issue, i.e. statements and expressions handled differently; but if we could in some future, we would appreciate it; at the moment we use listings and include the sagecode from external files;

by the way, since this is not only a sagemath issue but also a tex issue: perhaps you know Dante, the german speaking TeX User Group (www.dante.de); I am a board member and the treasurer of this group and we could offer funding, if someone from the community applied for it; but mind we cannot pay man hours, but only e.g. hardware or travelling expenses; so please let me know if we could help!

Doris

On 14. Oct 2021, at 13:26, Dima Pasechnik @.***> wrote:

Could you provide few more details: would you like to be able to include the output of a Sage command in a terminal session? Something else?

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

dantetante commented 2 years ago

Oh I did not know that the email will be integrated here and stripped from the attachment, so here it is before now

:

dimpase commented 2 years ago

How about using sagecommandline ? E.g.

\begin{sagecommandline}
  sage: factor(x^2 + 2*x + 1)
\end{sagecommandline}

will generate, in the final document, something like (colours might be off):

sage: factor(x^2 + 2*x + 1)                                                 42
(x + 1)^2                                                                   43

i.e. with line numbers (here start from 42 as an example) on by default - but they can be suppressed.

dimpase commented 2 years ago

Hi Doris, thanks for letting me know about http://dante.de funding options. Are they for (Germany-based, or not only?) individuals? Open-source orgs in general? Dima

dimpase commented 2 years ago

sagecommandline

just like other non-graphics SageTeX commands, puts the Sage output into foo.sagetex.scmd (assuming you work with foo.tex).

Regarding pictures: the generated plots (in sage-plots-for-foo.tex) are included using calls to the relevant graphics macros (e.g. includegraphics - and sageplot can pass parameters to it) in SageTeX LaTeX macros (e.g. sageplot).