# Saving a plot as a pdf to use in Latex

I use the following code:

sol = DSolveValue[{y'[t] == 1/(2 y[t] + 3), y[0] == 1}, y, t];
Plot[sol[t], {t, -10, 10}, ImageSize -> Small]


Then I Ctrl+click the image (Macbook Pro) and save the image as test.pdf.

Then, in the same folder, I write the following latex code:

\documentclass[12pt]{article}
\usepackage{graphicx}
\begin{document}
\includegraphics{test.pdf}
\end{document}


I compile using pdflatex and I get the following image.

Is this a bug?

• Can you include what Mma version and OS you are using. There are some known problems with PDFs in V10 Jan 20 '15 at 4:57
• Very closely related: mathematica.stackexchange.com/q/68893/131 Jan 20 '15 at 5:58
• I am using Mathematica 10.0.2, macbook pro Yosemite 8.0.2, machete texlive 2014. I Ctrl+clicked the image in my notebook, selected Save Graphic As..., then selected PDF from the format list. Jan 20 '15 at 15:25

This looks like a bug related to exporting via the context menu. Try exporting using:

sol = DSolveValue[{y'[t] == 1/(2 y[t] + 3), y[0] == 1}, y, t];
p = Plot[sol[t], {t, -10, 10}, ImageSize -> Small]
Export[NotebookDirectory[] <> "test.pdf", p, "PDF"]

• I would recommend Export[NotebookDirectory[]<>"test.pdf",p, "PDF"]. Jan 20 '15 at 3:54
• Yes you are right. Relying on Mathematica to infer the export format might not be a great idea. Jan 20 '15 at 3:58
• This worked for me, so I do think we have discovered a bug. Jan 20 '15 at 15:36

In generally, I used the method as below:

Plot[Sin[x], {x, -\[Pi], \[Pi]}]


Select the output cell -> Save selected as -> sample.pdf

\documentclass[b5paper,UTF8]{article}
\usepackage{graphicx}
\begin{document}
\texttt{Plot[Sin[x], {x, -Pi, Pi}]}

\vspace{1mm}
\fbox{\includegraphics[width=.9\textwidth]{sample.pdf}}
\vspace{1mm}
\end{document}