File Exchange

image thumbnail


version (2.1 KB) by Emmett L
PDF file exportation with LaTeX text and symbols

1 Download

Updated 25 Jul 2008

No License

PLOTPDFTEX renders all of the text in a Matlab figure with LaTeX (using LaPrint) and then saves it as a single pdf file for easy inclusion in a LaTeX document using pdflatex.

This function is an extension of PlotEpsTex, but also includes a bug fix so that line thickness and text size can be controlled.

Cite As

Emmett L (2020). PlotPdfTex (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (5)

Ewan Short

Hi Emmett,

I'm getting the following error when calling plotpdftex.m

Error using laprint (line 788)
This is not a figure handle.

Error in plotpdftex (line 102)
% Generate the EPS/LaTeX file


Ewan Short


Really nice tool! I've also had problems with eps2eps: when using plotyy, it removes the left y-axis. As mentioned in the comments, this is fixed for me by using Str = sprintf('ps2epsi %s.eps',TempName,FileName); instead. I also use matlabfrag instead of laprint, which in my opinion gives better results.

jan verveckken

Great tool, finally a solution for this problem!

Have had some trouble with a eps2eps, it would change the bounding box to cut off the axes... replaced it with the ps2epsi as suggested in your file, seems to handle that issue.


The file works nicely and based on plotepstex. However, there is a bug in the function:
The function creates an eps file called and deletes this temporary file after the pdf has been created.
While this itself is no problem, the function uses the same base string for the eps as for the pdf. Now, if I created a eps with that name before, e.g., using 'plotepstex', it is deleted by 'plotpdftex'.
To fix this, simply change the function such that it uses a (second) temporary file name instead of the string given by the user. Here's the diff output (diff new old):

< Str = sprintf('eps2eps -dNOCACHE %s3.eps',TempName,TempName);
> Str = sprintf('eps2eps -dNOCACHE %s.eps',TempName,FileName);
< Str = sprintf('epstopdf --outfile=%s.pdf %s3.eps',FileName,TempName);
> Str = sprintf('epstopdf %s.eps',FileName);
< dos(sprintf('rm %s3.eps',TempName));
> dos(sprintf('rm %s.eps',FileName));
< dos(sprintf('del %s3.eps',TempName));
> dos(sprintf('del %s.eps',FileName));
< %dos(sprintf('rm %s.eps',FileName));
> dos(sprintf('rm %s.eps',FileName));
< %dos(sprintf('del %s.eps',FileName));
> dos(sprintf('del %s.eps',FileName));

Emmet, if you could consider this please for an update.

Thanks for the function, works nicely apart from the above mentioned.

Sagren Munsamy

This was exactly what I was looking for. I spent hours trying to combine the laprint generated files. I was compiling using pdflatex so I needed to have a combined rendering of the laprint generated files. Thank you for this submission. A true timesaver!

MATLAB Release Compatibility
Created with R2007b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Inspired by: LaPrint, PlotEpsTeX

Inspired: matlabfrag to pdf

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!