# Inserting graph from a software in Latex

I made a graph with Desmos.com.

Which I want to insert in my LaTeX code, on the right side of these equations:

\documentclass[12pt,a4paper]{article}
\usepackage[a4paper, total={6in, 8in}]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fourier}
\usepackage{mathtools}
\usepackage{amsmath}
\usepackage[english]{babel}
\usepackage{graphicx}
\usepackage{marginnote}
\begin{document}
\underline {Chandrashekhar EOS (1935)} : \\
\begin{align*}
\overline \rho &= K ~\Big( \sinh ~t ~- ~t\Big)\\
\overline P &= \frac {1}{3} K ~ \Big(\sinh~t -~ 8~ \sinh \frac {1}{2} t  +~ 3t\Big)\\
K &= \frac {1}{4\pi}\\
\end {align*}
\end {document}


How can I label the curve on the graph as P and T and also insert it in my code ?

• Why not to use pgfplots for this? – m0nhawk Aug 7 '14 at 10:48
• You can use 2 minipages or 2 \parboxes or put them in a tabular/tabularx etc for the second question. But you are asking two questions here. Better separate them as two different questions. – user11232 Aug 7 '14 at 11:01
• How do you export the graph from Desmos? In a SVG, JPG, whatever image file? – Keks Dose Aug 7 '14 at 11:03
• I was trying to get it in .PNG , though failed . anyway I heard of pgfplots right here, I have never tried it before, can someone show me an example of it using my equations in the code? – Tazkera Haque Trina Aug 7 '14 at 12:45
• @papiro, closers: The suggested duplicate is about beamer, and the accepted answer (the only answer) use beamer specific features. – Torbjørn T. Aug 7 '14 at 12:51

Sorry this didn't get an answer earlier. But anyway, here is an example using pgfplots and a minipage environments.

\documentclass[12pt,a4paper]{article}
\usepackage[a4paper, total={6in, 8in}]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fourier}
\usepackage{mathtools}
\usepackage[english]{babel}
\usepackage{graphicx}
\usepackage{marginnote}
\usepackage{pgfplots}
\pgfplotsset{compat=1.13}
\begin{document}
\underline {Chandrashekhar EOS (1935)}:

\noindent\begin{minipage}{0.45\textwidth}
\begin{align*}
\overline \rho &= K \Big( \sinh t - t\Big)\\
\overline P &= \frac {1}{3} K ~ \Big(\sinh t - 8 \sinh \frac {1}{2} t  + 3t\Big)\\
K &= \frac {1}{4\pi}\\
\end {align*}
\end{minipage}\hfill
\begin{tikzpicture}[baseline=(theAxis.west)]
\begin{axis}[
name=theAxis,
ymin=-15,ymax=15,
domain=-8:8,
samples=50,
no markers,
cycle list name=exotic,
thick,
width=0.48\textwidth,
grid,
xlabel=$t$,
ylabel={Something}
%% if you want a legend, uncomment these
%  legend entries={$\overline{\rho}$, $\overline{P}$},
%  legend pos=north west
]
\addplot {(sinh(x) - x)/(4*pi)} node[left,pos=0.53]{$\overline{\rho}$};
\addplot {(sinh(x) - 8*sinh(x/2) + 3*x)/(3*4*pi)} node[right,pos=0.6]{$\overline{P}$};
\end{axis}
\end{tikzpicture}
\end {document}


If you export the graph from Desmos as e.g. a PNG image, you can do something like this instead, where the image is called graph.png and is in the same folder as the .tex file. The drawback of this method is that the image will likely require scaling, which will also scale the fonts.

\underline {Chandrashekhar EOS (1935)}:

\noindent\begin{minipage}[b]{0.45\textwidth}
\begin{align*}
\overline \rho &= K \Big( \sinh t - t\Big)\\
\overline P &= \frac {1}{3} K ~ \Big(\sinh t - 8 \sinh \frac {1}{2} t  + 3t\Big)\\
K &= \frac {1}{4\pi}\\
\end {align*}
\end{minipage}\hfill
\includegraphics[width=0.45\textwidth]{graph}