Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Views: 29892
1
\documentclass[master.tex]{subfiles}
2
3
\setcounter{chapter}{3}
4
5
\begin{document}
6
7
\chapter{SageTeX}
8
\label{sec:sagetex}
9
10
11
\section{SageTeX and \texttt{latexmk}}
12
13
\texttt{latexmk} is a versatile utility for building \LaTeX documents.
14
It automatically learns about the inter-dependencies of all
15
documents and generated intermediate files.
16
It uses this information to run and repeatedly re-run various tools
17
to produce a working final document.
18
19
To make it work well with SageTeX,
20
the file \texttt{latexmkrc} in the current directory defines
21
additional dependencies and instructions.
22
23
For more information, type a terminal \texttt{man latexmk}.
24
25
To enable SageTeX in combination with \texttt{latexmk},
26
this page explains how to modify the \texttt{latexmkrc} file:
27
28
\url{https://github.com/dandrake/sagetex/wiki}
29
30
Little caveat: to make it work in this demo,
31
a small wrapper script ``\texttt{run-sagetex.py}''
32
handles the filename and calling in order to work with SageTeX
33
correctly.
34
35
\section{SageTeX Demo}
36
37
1 + 1 = \sage{1+1}
38
39
% this is only processed in SageMath and not displayed
40
\begin{sagesilent}
41
x = var('x')
42
ex = (1 + x)^5
43
exe = ex.expand()
44
\end{sagesilent}
45
46
$\sage{ex} \rightarrow \sage{exe}$
47
48
Raw Strings:
49
50
%\sagestr{str(CartesianProduct(['a', 'b'], [1, 2, 3]).list())}
51
52
Defining a function g:
53
54
\begin{sageblock}
55
a = 2
56
b = 3
57
x = var('x')
58
g = a * sin(b * x) + sqrt(x)
59
\end{sageblock}
60
61
And a plot of $g = \sage{g}$ from $[0, 10]$:
62
63
\sageplot[width=.5\textwidth]{plot(g, 0, 10)}
64
65
\end{document}
66
%sagemathcloud={"latex_command":"make '40-sagetex.pdf'"}
67
68