# Is there a TeX/LaTeX maths workbook like Sympy live shell?

I am looking for a mathematics workbook like Sympy live shell that you can do plots in, that has a TeX or LaTeX output.

• Hi, welcome. What exactly do you mean by "LaTeX output"? – Torbjørn T. Feb 27 '17 at 19:56
• the best example I can give is this: live.sympy.org The sympy live shell will calculate a python input and produce the output rendered in LaTex. Sage math can output raw LaTex, I was curious if there was a way to make it output rendered LaTex. – Anon Feb 27 '17 at 20:18
• Now I'm just more confused. By "raw LaTeX", do you mean code? And the output from Sage you're talking about; output of what, exactly? You were talking about plots, do you mean just any plot that can be used in LaTeX (which could just be a .pdf file, or .png file), or do you want code using e.g. the pgfplots or pstricks package that will render to a plot? – Torbjørn T. Feb 27 '17 at 20:24
• by "raw LaTeX" I mean code, for example: f(x) = x^2 latex( f) would produce: x \ {\mapsto}\ x^{2}. by plots I mean for example the plot of $x^{2}$ and its derivative – Anon Feb 27 '17 at 20:36

If you're familiar with the Sage Cloud and Python, just use that. You'll have access to all the goodies of sympy, and you can save the plots as for example PDF files, that can be used in a LaTeX document with \includegraphics.

For example if you have

import matplotlib.pyplot as plt
import numpy as np
import sympy as sp
fig,ax = plt.subplots(figsize=(3,2))
ax.plot(np.random.rand(20))
fig.savefig('test.pdf',bbox_inches='tight')


in a Sage worksheet and run that, you will get test.pdf in the project folder, that can then be downloaded, and used in a LaTeX file as

\documentclass{article}
\usepackage{graphicx}
\begin{document}
\includegraphics{test}
\end{document}