ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 13 Apr 2020 20:46:01 +0200Keep getting ?? as output instead of the desried sage output in sageexamplehttps://ask.sagemath.org/question/50731/keep-getting-as-output-instead-of-the-desried-sage-output-in-sageexample/Hi!
So a total beginner in sage here so please try to refrain from suggesting too technical things here.
I'm trying to have some sage code results show in my tex file. After reading some parts of sage tutorial in example.pdf, I made another small tex file with
>
\documentclass{article}
\usepackage{sagetex}
\begin{document}
\begin{sageexample}
sage : E = EllipticCurve([0,3])
sage : E.discriminant()
\end{sageexample}
\end{document}
Ran this tex file, then associated example.sagetex.sage file in terminal, then ran tex file again but all I keep getting is ?? Instead of the desired output.
What am I missing or doing wrong?
The first eror latex suggested is - Reference '@sageinline0' on page 1 undefined on input line 6.
Package sagetex warning: there were undefined Sage formulas and/or plots.
Run Sage on example.sagetex.sage, and then run LaTeX on example.tex again.
But what should I do?
Thanks you.
Edit: Sorry for not embedding the minimal working example right, I'm on mobile and new to this site so don't know exactly how to do that yet. Would appreciate pointers on that as well if possible.Mon, 13 Apr 2020 19:27:52 +0200https://ask.sagemath.org/question/50731/keep-getting-as-output-instead-of-the-desried-sage-output-in-sageexample/Answer by dsejas for <p>Hi! </p>
<p>So a total beginner in sage here so please try to refrain from suggesting too technical things here. </p>
<p>I'm trying to have some sage code results show in my tex file. After reading some parts of sage tutorial in example.pdf, I made another small tex file with</p>
<blockquote>
<p>\documentclass{article}</p>
</blockquote>
<p>\usepackage{sagetex}
\begin{document}
\begin{sageexample}
sage : E = EllipticCurve([0,3])
sage : E.discriminant()
\end{sageexample}
\end{document}</p>
<p>Ran this tex file, then associated example.sagetex.sage file in terminal, then ran tex file again but all I keep getting is ?? Instead of the desired output. </p>
<p>What am I missing or doing wrong? </p>
<p>The first eror latex suggested is - Reference '@sageinline0' on page 1 undefined on input line 6. </p>
<p>Package sagetex warning: there were undefined Sage formulas and/or plots.
Run Sage on example.sagetex.sage, and then run LaTeX on example.tex again. </p>
<p>But what should I do? </p>
<p>Thanks you.</p>
<p>Edit: Sorry for not embedding the minimal working example right, I'm on mobile and new to this site so don't know exactly how to do that yet. Would appreciate pointers on that as well if possible.</p>
https://ask.sagemath.org/question/50731/keep-getting-as-output-instead-of-the-desried-sage-output-in-sageexample/?answer=50732#post-id-50732Hello, @Shreya!
When you compile your LaTeX document, SageTeX extracts all the Sage code in a separate file. This file contains all the information of what should be computed, how to compute it, and where to write it. However, the file is not automatically executed. I think this is a security measure, since it would be unwise to automatically execute Sage code from a LaTeX file from an unknown or untrusted source. If that were the case, you would have all the code extracted, you can read it and then execute it if you trust it.
What you have to do is to manually execute that file (if you are using a TeX IDE, like TeXstudio, you can make that process automatic or configure it for a shortcut). For example, if your LaTeX document is called "hello_world.tex", after you run `latex` or `pdflatex` or `lualatex`, you will see a file called "hello_world.sagetex.sage". Go to your terminal and execute
sage hello_world.sagetex.sage
You will see a quite verbose output printed in your screen. If everything goes right, you will now have a file called "hello_world.sagetex.py" and another called "heel_world.sagetex.out" (and perhaps other similar). That's it! Re-compile your LaTeX document, and you will see the output you needed automatically typeset in your file.
I hope this helps! Feel free to ask any doubt you have.
And welcome to the marvelous world of SageMath!Mon, 13 Apr 2020 20:46:01 +0200https://ask.sagemath.org/question/50731/keep-getting-as-output-instead-of-the-desried-sage-output-in-sageexample/?answer=50732#post-id-50732