Displaying Sagetex code

79 views
Skip to first unread message

Harald Helfgott

unread,
Mar 18, 2018, 2:28:02 PM3/18/18
to sage-support
it is possible to

(a) display Sagetex code within TeX in a relatively "clean" fashion (one that can be sent to referees, say, rather than just to one's friends),
(b) make variable names appear as footnotes to their values, when displayed via \sage (as opposed to \sageblock)? Again, the purpose would be debugging/refereeing.


Emmanuel Charpentier

unread,
Mar 19, 2018, 6:59:09 AM3/19/18
to sage-support


Le dimanche 18 mars 2018 19:28:02 UTC+1, Harald Helfgott a écrit :
it is possible to

(a) display Sagetex code within TeX in a relatively "clean" fashion (one that can be sent to referees, say, rather than just to one's friends),

That's what sageblock is supposed to do...

If you want to refine the presentation of your code, you might use an external file (possibly generated froM the \LaTeX code itself, see my answer to my own ask.sagemath.org question), then using \lstinputlisting or \minted to your heart's content...

(b) make variable names appear as footnotes to their values, when displayed via \sage (as opposed to \sageblock)? Again, the purpose would be debugging/refereeing.

??? Could you give us an example of what you want to do ? I have trouble visualizing it...

--
Emmanuel Charpentier

John Cremona

unread,
Mar 19, 2018, 7:04:22 AM3/19/18
to SAGE support
Harald, you might be interested in this example:  https://arxiv.org/src/1306.6818v3/anc/X13.pdf

John Cremona

--
You received this message because you are subscribed to the Google Groups "sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscribe@googlegroups.com.
To post to this group, send email to sage-s...@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.

Harald Helfgott

unread,
Mar 25, 2018, 9:20:23 AM3/25/18
to sage-support

(b) make variable names appear as footnotes to their values, when displayed via \sage (as opposed to \sageblock)? Again, the purpose would be debugging/refereeing.

??? Could you give us an example of what you want to do ? I have trouble visualizing it...


--------
\begin{sageblock}
 a = 140
 b = 10
 res = a*b
\end{sageblock}

It is easily seen that our constant is $\sage{res}$.
-------------

I want to display:

It is easily seen that our constant is $10^{\text{\texttt{res}}}$.

Harald Helfgott

unread,
Mar 25, 2018, 9:21:37 AM3/25/18
to sage-support
(Well, I want to display what that LaTeX code would display, obviously.)

slelievre

unread,
Mar 26, 2018, 5:33:57 AM3/26/18
to sage-support

%%% file.tex
\documentclass{article}

\usepackage{sagetex}
\usepackage{amsmath}

\begin{document}

\begin{sageblock}
a = 140
b = 10
res = a*b
\end{sageblock}

It is easily seen that our constant is $10^{\text{\texttt{\sage{res}}}}$.

\end{document}

%%%
$ pdflatex file.tex
$ sage file.sagetex.sage
$ pdflatex file.tex
$ open file.pdf

Harald Helfgott

unread,
Apr 4, 2018, 5:35:02 AM4/4/18
to sage-support

That is not what I meant. I meant that the label would appear above the variable (though I now realize it would be better for it to appear on top of the variable, to avoid confusion with exponents - though of course confusion with subscripts would still be possible).

slelievre

unread,
Apr 6, 2018, 3:24:42 AM4/6/18
to sage-support
When you wrote:

> --------

> \begin{sageblock}
> a = 140
> b = 10
> res = a*b
> \end{sageblock}
>
> It is easily seen that our constant is $\sage{res}$.
> -------------

> I want to display:
>
> It is easily seen that our constant is $10^{\text{\texttt{res}}}$.

did you mean you wanted it to display

    It is easily seen that our constant is $1400^{\text{\texttt{res}}}$.

where "1400" is the value of "res" and "\texttt{res}" is its "label"?

slelievre

unread,
Apr 6, 2018, 4:13:49 AM4/6/18
to sage-support
I would suggest defining a new command in the LaTeX preamble.
Here is a starting point, adapt to your taste:

\newcommand{\sagenote}[1]{$\text{\texttt{#1}} = \sage{#1}$}

Example for testing:

%%%
\documentclass{article}

\usepackage{sagetex}
\usepackage{amsmath}

\newcommand{\sagenote}[1]{$\text{\texttt{#1}} = \sage{#1}$}

\begin{document}

\begin{sageblock}
a = 140
b = 10
res = a*b
\end{sageblock}

It is easily seen that our constant is \sagenote{res}.

\end{document}​
%%%

Of course, instead of A = B, you could stack A on top of B,
or insert an arrow, a brace, etc.

See eg Herbert Voss's "Mathmode", section 66 "Node connections".
Or in the same document: underbrace, overbrace, underbracket,
overbracket, stackrel, colorbox, empheq...
Or use TikZ to create arrows etc.


Reply all
Reply to author
Forward
0 new messages