Embedding Sage plots in PDF file using Sagetex

Here is the code to do this: (embedplot.tex)

\documentclass{article}
\title{Embedding graphs plotted by SAGE in \LaTeX}
 \author{Priyanka Kapoor}
\usepackage{sagetex}

 \begin{document}
 \maketitle


Using Sage\TeX, one can use Sage to compute things and put them into
your \LaTeX{} document. Following is the example showing this.

Here's some Sage code:

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

\end{sageblock}

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

\sageplot{plot(f, -1, 1,figsize=[3,2])}

 \end{document}

Run the file using commands:

$ latex embedplot.tex
$sage embedplot.sagetex.sage
$pdflatex embedplot.tex
$evince embedplot.pdf

If you want to change the plot, just change f(x) and you will get a new plot.

 

Advertisements

About Priyanka Kapoor

Simple, Hardworking & friendly.....
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s