| Download
Github repo cloud-examples: https://github.com/sagemath/cloud-examples
Project: Support and Testing
Views: 8060License: MIT
\documentclass[master.tex]{subfiles}12\setcounter{chapter}{3}34\begin{document}56\chapter{SageTeX}7\label{sec:sagetex}8910\section{SageTeX and \texttt{latexmk}}1112\texttt{latexmk} is a versatile utility for building \LaTeX documents.13It automatically learns about the inter-dependencies of all14documents and generated intermediate files.15It uses this information to run and repeatedly re-run various tools16to produce a working final document.1718To make it work well with SageTeX,19the file \texttt{latexmkrc} in the current directory defines20additional dependencies and instructions.2122For more information, type a terminal \texttt{man latexmk}.2324To enable SageTeX in combination with \texttt{latexmk},25this page explains how to modify the \texttt{latexmkrc} file:2627\url{https://github.com/dandrake/sagetex/wiki}2829Little caveat: to make it work in this demo,30a small wrapper script ``\texttt{run-sagetex.py}''31handles the filename and calling in order to work with SageTeX32correctly.3334\section{SageTeX Demo}35361 + 1 = \sage{1+1}3738% this is only processed in SageMath and not displayed39\begin{sagesilent}40x = var('x')41ex = (1 + x)^542exe = ex.expand()43\end{sagesilent}4445$\sage{ex} \rightarrow \sage{exe}$4647Raw Strings:4849\sagestr{str(CartesianProduct(['a', 'b'], [1, 2, 3]).list())}5051Defining a function g:5253\begin{sageblock}54a = 255b = 356x = var('x')57g = a * sin(b * x) + sqrt(x)58\end{sageblock}5960And a plot of $g = \sage{g}$ from $[0, 10]$:6162\sageplot[width=.5\textwidth]{plot(g, 0, 10)}6364\end{document}65%sagemathcloud={"latex_command":"make '40-sagetex.pdf'"}666768