View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from

4.5 | 2 ratings Rate this file 8 Downloads (last 30 days) File Size: 28.8 KB File ID: #41894 Version: 1.0
image thumbnail




This package enables the use of all fonts that are supported by LaTeX in a figure.

| Watch this File

File Information

The creation of really beautiful and publishable graphs with Matlab is not easy but possible.
However once you want to export your file you run into many problems, which are based on build in problems (bugs) of Matlab which have not been fixed since years.

The two most important bugs are the missing font support and wrong linestyles.

The function 'latexfigure' is an approach to solve this problem. It is basically a wrapper to several existing functions for the solution of these problems.

It was inspired by mlf2pdf and uses matlabfrag to get around the
eps font problem. However I had to patch matlabfrag to support also non math fonts.

The linestyles are corrected using the ‘fix_lines.m’ script from export_fig.

The major drawback of this approach is that it requires a complete LaTeX collection to create a pdf version of the figure, which can than be converted afterwards in the target format using ghostscript.

The code is hosted at


Matlabfrag To Pdf, Split Delimiter Separated Strings Into A Matrix, Export Fig, and Savefig inspired this file.

Required Products MATLAB
MATLAB release MATLAB 7.12 (R2011a)
Other requirements pdflatex, ghostscript
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (3)
17 Mar 2014 Peter

Peter (view profile)

It works now and it looks nice. '$$f_u$$' does not work, but '$f_u$' works.

17 Mar 2014 Octopode

it doesn't work. All figures were processed flawlessly by mlf2pdf, but with this routine, whatever i do, i get this :

No delimiter in string, inputString is returned
Cell contents reference from a non-cell array object.

Error in latexfigure/createLaTeXFile (line 178)
fprintf(fid,'%s\n',split{i}); % Suplementary LaTeX Code

Error in latexfigure (line 100)

Comment only
25 Jun 2013 Jan

Jan (view profile)

I have used the script excessively and it has produced a lot of nice looking figures. But I have one issue with it.

I define a size for the legend using a four element vector for the setting of the ‘location’ but MATLAB is widening the legend so that the entry for the legend fits. When I use for the example of a revolution speed
$n = 500/\textrm{min}$
I get a very wide legend with a big white edge after latexfigure converts the term to n = 500/min.

Does somebody know a way/workaround to narrow down the legend?

Contact us