Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Go to Cocalc and create a new latex file. In it, copy/paste the following code that you seem to be using from here:

\documentclass{article}
\usepackage{sagetex}
\begin{document}
Using Sage\TeX, one can use Sage to compute things and put them into
your \LaTeX{} document. For example, there are
$\sage{number_of_partitions(1269)}$ integer partitions of $1269$.
You don't need to compute the number yourself, or even cut and paste
it from somewhere.

Here's some Sage code:

\begin{sageblock}
    f(x) = exp(x) * sin(2*x)
\end{sageblock}

The second derivative of $f$ is

\[
  \frac{\mathrm{d}^{2}}{\mathrm{d}x^{2}} \sage{f(x)} =
  \sage{diff(f, x, 2)(x)}.
\]

Here's a plot of $f$ from $-1$ to $1$:

\sageplot{plot(f, -1, 1)}
\end{document}

Save the document and press the Build button. This will run latex on the document, then Sage, then latex so you will have to wait a few seconds. At the end the document comes out but some places have ?? in them where Sage output should go. This shouldn't happen. I have reported the issue to Cocalc. Now change \sageplot{plot(f, -1, 1)} to \sageplot[width=3in]{plot(f, -1, 1)}. Save and Build. You should now get the result and there are no ?? to be found. However, your plot is much to big. This is the result that we should have gotten the first time we pressed Build and got ??. Now change \sageplot[width=3in]{plot(f, -1, 1)} to \sageplot{plot(f, -1, 1)}. Save and Build. The document should now look okay. The plot is smaller. This is the output we should have gotten from our previous Build. Hopefully Cocalc will fix the issue quickly.

With respect to running sagetex without using Cocalc, it's not clear to me what you're doing. First, sagetex should be part of your Latex distribution so I don't think you need to download sagetex-3.3.tar.gz. When you process using latex use TexMaker make sure it's running pdflatex rather than 'latex. The instructions [here](https://tex.stackexchange.com/questions/251459/strange-result-when-trying-to-use-sagetex) will explain how to proceed. You should end up with a.pdffile. If you don't check the.log` file for an error as to what went wrong.

Go to Cocalc and create a new latex file. In it, copy/paste the following code that you seem to be using from here:

\documentclass{article}
\usepackage{sagetex}
\begin{document}
Using Sage\TeX, one can use Sage to compute things and put them into
your \LaTeX{} document. For example, there are
$\sage{number_of_partitions(1269)}$ integer partitions of $1269$.
You don't need to compute the number yourself, or even cut and paste
it from somewhere.

Here's some Sage code:

\begin{sageblock}
    f(x) = exp(x) * sin(2*x)
\end{sageblock}

The second derivative of $f$ is

\[
  \frac{\mathrm{d}^{2}}{\mathrm{d}x^{2}} \sage{f(x)} =
  \sage{diff(f, x, 2)(x)}.
\]

Here's a plot of $f$ from $-1$ to $1$:

\sageplot{plot(f, -1, 1)}
\end{document}

Save the document and press the Build button. This will run latex on the document, then Sage, then latex so you will have to wait a few seconds. At the end the document comes out but some places have ?? in them where Sage output should go. This shouldn't happen. I have reported the issue to Cocalc. Now change \sageplot{plot(f, -1, 1)} to \sageplot[width=3in]{plot(f, -1, 1)}. Save and Build. You should now get the result and there are no ?? to be found. However, your plot is much to big. This is the result that we should have gotten the first time we pressed Build and got ??. Now change \sageplot[width=3in]{plot(f, -1, 1)} to \sageplot{plot(f, -1, 1)}. Save and Build. The document should now look okay. The plot is smaller. This is the output we should have gotten from our previous Build. Hopefully Cocalc will fix the issue quickly.

With respect to running sagetex without using Cocalc, it's not clear to me what you're doing. First, sagetex should be part of your Latex distribution so I don't think you need to download sagetex-3.3.tar.gz. When you process using latex use TexMaker make sure it's running pdflatex rather than 'latexlatex. The instructions [here](https://tex.stackexchange.com/questions/251459/strange-result-when-trying-to-use-sagetex) here will explain how to proceed. You should end up with aa .pdf file. If you don't check the.log` the .log file for an error as to what went wrong. wrong.