No BSD License  

Highlights from


4.5 | 81 ratings Rate this file 179 Downloads (last 30 days) File Size: 97.9 KB File ID: #4638




16 Mar 2004 (Updated )

LaPrint prints a MATLAB figure to file for neat inclusion in LaTeX documents.

| Watch this File

File Information

LaPrint is a MATLAB function to print MATLAB graphics for inclusion in LaTeX documents. LaPrint creates an eps-file and a tex-file. The tex-file contains the annotation of the figure such as titles, labels and texts. The eps-file contains the non-text part of the figure and is called by the tex-file.

The main advantage of using LaPrint is that the annotation can be neatly (e.g., including math mode and fancy font constructs) set within LaTeX. LaPrint can be used from the command line or via a graphical user interface (GUI).

Current Version is 3.16. Matlab 6.1 or above is required.

An Users Guide for LaPrint is available at


This file inspired Plot2eps, Plot Pdf Tex, Plot Eps Te X, Legend To Latex Converter, Matlabfrag, and Export Eps Pdf.

MATLAB release MATLAB 7 (R14)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (91)
29 Oct 2013 Johannes Schmitz

On Ubuntu 13.04 I am getting this error:
/usr/bin/gs: /opt/MATLAB/R2013a/bin/glnxa64/ no version information
available (required by /usr/lib/

I copied the from my system folder into the Matlab folder and changed the symolic link ( from to as a workaround.

08 Oct 2011 Thomas Clark

Potentially very useful, as this is an area in which the Mathworks' own solutions are woeful with no signs of improvement. However, with no updates since 2004 I'm not holding my breath for vital fixes to this utility.

For me, the main problems are:
- using texShop on a Mac, and the tags simply aren't being updated so are typeset in the finished document as x01, x02 etc (to be fair this might be a latex issue).
- axes scales (x10^p etc) are placed incorrectly
- legend sizes aren't handled

... and that's before trying anything challenging like having patch objects or 3D plots etc.

Some users may consider googling for psfragx and psfragx.m, which allow overlays of pictures and inclusion of graphics in a more flexible way within latex. Still reliant on Laprint though, so the bugs above won't go away.

24 Aug 2011 Pavle Boskoski

There is a small Bug in the script when using it with 3D plots. The z-axis is not preserved. The solution is:
The lines 1189 to 1191 and 1782 to 1784 should be changed from:
-set(ztickmodeauto,'ytickmode','manual') -set(zticklabelmodeauto,'yticklabelmode','manual')

+set(zlimmodeauto,'zlimmode','manual') +set(ztickmodeauto,'ztickmode','manual')

The only problem was a typo, when setting zticklabel modes the actual property was ylabel.

Great work BTW!

11 Aug 2011 sweta  
11 Feb 2011 Waseem Tahir

These type of programs seem very nice at first glance, however you come to trouble when it come to real issues. i wasted about 3 hours on laprint, however at end i come to conslusion that title('$\hat{a}$','Interpreter','latex') is the best. you loose flexibility when using laprint.

03 Nov 2010 hassene

try this out, very easy and works well !

19 Mar 2010 Erik

Would it be possible in a future version to set the width of the picture like this:

laprint(1,nameoffile,'width','.9\linewidth ')

In other words: describe the width not as a number but as a factor of the linewidth?

30 Sep 2009 Emile Demarteau

Great work! This script allowed me to perfectly markup all my figures, so they could be included nicely in my report. @Tor Aksel, I wrote a legend to latex converter to overcome the small box problem.

30 Sep 2009 Emile Demarteau  
16 Sep 2009 Robert  
15 Sep 2009 Tor

Extraordinary work. However, I have two problems. The legend box sometimes gets too small, and must be enlarged manually. Also, when the x-axis has ticks as powers of 10, the "x10^n" does not appear in the eps. From inspecting the code, it seems this s only implemented for the y-axis.

13 Jul 2009 Ty

I was trying to specify a destination directory with the filename, for example,
laprint(1, './figure/a', 'options', 'factory', 'width', 7.5)

Two files will be generated in directory 'figure', namely, 'a.eps' and 'a.tex'

On the Windows machine, the '\includegraphics{}' (second line from bottom in 'a.tex') will points to the correct path of 'a.eps.'
However, on the Linux and Mac machine, the correct path won't be appended to the argument in '\includegraphics{}.'

Any suggestion?

12 Jun 2009 James Mynderse  
05 May 2009 Pavle Boskoski

Very valuable script. I can't understand why matworks did't include such script in their package.


16 Apr 2009 Mark Verveld

I solved the ypower-text issue by adding the folowing lines after line 1563:
It ensures that the power text is actually printed to the intended axes of the intended figure.

Very good work though, thanks!

14 Oct 2008 Cun Zhang

Great Work!

19 Sep 2008 Peter B

Sorry for the double post. Here is the last line that should've been in the previous post

??? Error while evaluating uicontrol Callback.

19 Sep 2008 Peter B

I get the following error when I execute laprint and I have no idea what it could be! Can anyone please help?

??? Error: Missing MATLAB operator.

Error in ==> laprint at 1795

Error in ==> laprint at 415

17 Sep 2008 Kevin Mitchell

Beautiful! This is exactly what I need. It works just as advertised. I have yet to find a case where I can't use this package to produce the figure I want.

My only caveat is that as a rule, I generally use 'figcopy','off' to avoid any problems with matlab's object copy function , but I could really care less since I generate any serious figures (i.e., ones that I would actually want to include in a latex document) from scripts anyway.

This package really should be included in the standard Matlab distribution.

04 Sep 2008 knowline knowline  
04 Sep 2008 Steve _

y-axis power appears in wrong place when a legend is present (due to the powers tag placed with text() when legend axes is current instead of main axes).

Fixed with the following changes between lines 1560 and 1575 (this may cause unwanted side effects - I've not noticed any yet):

% place text to be replaced by powers on y-axis
+ % Bug fix: when legend is present, powers-string appears on legend axes
+ % instead of main axes; make sure main axes are current when invoking text();
+ % at the end, make legend axes current to make legend visible again
+ ca = gca; % if legend present, this is probably legend axes
for i=1:na
allxyz = { 'x', 'y', 'z' };
ixyz=2; % x,y,z
xyz = allxyz{ixyz};
if powers(i,ixyz) & ~is3d(hax(i)) & isequal(leftright,'left')
+ axes(hax(i)); % make the axes current
powertext = ['ypower' int2str(i)];
xlimit = get(hax(i),'xlim');
ylimit = get(hax(i),'ylim');
@@ -1575,6 +1587,7 @@
end % i
+ axes(ca); % needed to make legend visible again -- any side effect?

31 Jul 2008 ich aus Hannover

In general this is a very useful tool. But the proramm do not place the powers on the y-axis (ypower) correctly. And that is quite laborious to change the files by hand.

30 Jul 2008 Ivo visitor

Actually, I cannot use this on Ubuntu/Matlab 7.5 because the placeholders are not replaced correctly by the generated .tex file. I use texlive and the psfrag package. There are no errors on compilation with LaTeX but the labels are just not located at the correct positions. Also the 'straight line' from the user manual is printed horizontally, whereas it is the y-axis label (just following the example in the manual).
Is this a known problem? I have seen this on more than 1 computer).

Are there any thoughts on this? I would really like to use this tool.

24 Jul 2008 Olivier Lemaire

perfect !!
This is exactly what I need. Thank you so much.

Love LateX...

19 May 2008 The Rainman

This is actually cool and helpful!

15 Apr 2008 Jacob Huijssen

I love this function, very happy to discover it at the start of writing my PhD thesis!!

31 Jan 2008 Dai Jessop

Decent function, but one can achieve the same result using
> print -depsc <filename>

28 Jan 2008 Eric Johnson

An impressive and useful piece of work, indeed. After some head scratching, I found that the size of legends gets screwed up in MATLAB 7.4 if the figure is copied before doing the text replacements. To avoid this, use the 'figcopy', 'off' option from the command line or uncheck the "Copy figure and modify that copy" option in the gui. With that option set, the text in your original figure gets changed into the psfrag tags, but the legend size comes out correct.

10 Nov 2007 Rob Stanson

Helpful tool, but I had to make a change in order to be able to use ist with legends in Matlab 7.1:

I replaced line 1563
for i=1:na
for i=na:-1:1

because it placed the ypower-text into the legend's axes, not into the normal axes.

27 Oct 2007 Paul Miller

Excellent program. I would like to be able to specify a default font size for all labels, etc. For example, add \footnotesize to all tick labels.

10 Oct 2007 Javier Barragán

Is it possible to eliminate the warning of line 64 with this?

In the beginning of the function:

At the end or before any "return" or "error":

Thank you!

24 Sep 2007 Mark Morelande

Thank you for writing this excellent function. I have found it to be extremely useful.

17 Sep 2007 Jean-Christophe OLIVIER

Thank you very much for this powerfull function! All well work!

13 Jul 2007 S. Hoffmann

SUPERB TOOL! Only thing I am missing is the turning of axis lables in 3d plots. I also like to modify the distance of tick lables to the axis, because by default laprint sets them a little too far away from the axis (in my opinion). Nevertheless, greatly helpful! Thanks!

01 Jul 2007 sssssssss sas


27 Jun 2007 Jason Venkiteswaran

What about axis labels? I can't find an 'as on screen' option. This is important for converting EPS files to PDF for use with pdftex.

18 Jun 2007 Kyriakos Chourdakis

Excellent! Thanks a lot for that Arno

12 Jun 2007 Gernot Hassenpflug

To add to my previous review. I discovered belatedly that the renderers -zbuffer and -opengl store binary data, only -painters stores vector data and therefore only the latter can be used with LaPrint. This is not a bug, and I apologize for not having noted this in my first review. If one requires -opengl rendering then one will need to overlay plots in LaTeX using I suppose the pstricks and graphicx packages.

08 Jun 2007 Gernot Hassenpflug

I found this utility useful for simple plots, but I discovered that unfortunately it does not appear to work for renderers -opengl and -zbuffers. If one is forced to use -painters, then shading and lighting is lost in 3-D graphics. I could not discover where the problem lies, but since the .tex output appears the same, I surmise it is the .eps file format. I wish I had the ability to fix this, but for the moment I need to look for alternative tools.

11 May 2007 sara tamer  
10 May 2007 D T  
04 May 2007 Dimas Mavares

Extremely useful

13 Apr 2007 Guillaume Jacquenot

Excellent work. You spare me a lot of time!!

07 Mar 2007 Leopold Pede

I am student and like to learn Matlab

04 Feb 2007 murtaza kemal

a lot of things

04 Jan 2007 popo sskkd  
23 Nov 2006 Le Chen

It is very cool and useful!

07 Nov 2006 Jim Hoyes

Specifically, problems seem to arise when using different renderers.
I have problems when using zbuffer or opengl.

Anyone got any advise?

07 Nov 2006 Jim Hoyes

I am having problems using it for 3D plots.
Has anyone else had problems?
Or found any solutions?

31 Oct 2006 Ed Neson

Beautiful piece of work, I wish that it was available for octave.

26 Oct 2006 Lucien de Vaucanson

Very very very useful !

07 Oct 2006 tiago castro


23 Sep 2006 Sebastian Trimpe

Great help! Easy to use function!

21 Aug 2006 Thiago Fontes  
07 Aug 2006 ejan ajan

I tried to use it for importing my matlab 7.1.xx figures into latex. I referred to the manual and tried out different preferences, but still result not usable without considerable alterations that would cost too much time. Problem: labels and axes are not appropriately titled.

04 Aug 2006 Benjamin Auffarth

I tried to use it for importing my matlab 7.1.xx figures into latex. I referred to the manual and tried out different preferences, but still result not usable without considerable alterations that would cost too much time. Problem: labels and axes are not appropriately titled.

11 Jul 2006 Joe Dash  
10 May 2006 pipe espinoza  
09 May 2006 poienar marius  
09 May 2006 poienar marius  
09 May 2006 poienar marius  
08 May 2006 Patrick Egan

Fantastic file for dissertaions and reports.

It does not appear to work well with legends in Matlab 7.1.

10 Apr 2006 jkh lhl  
26 Mar 2006 Mustafa YILDIRIM

GOOD & REAL work/job/etc.... u r the one... Thankx...

03 Mar 2006 uuyhruyr rtur

tyh t6y7 t6y7 6t 56y

03 Mar 2006 tyuhtuy trytrt

yuyjhyuuyj tyt t5ytyty

08 Feb 2006 Jeroen Brunnenkreef

This can be used to get rid of the psfrag:

28 Jan 2006 baptiste auguie

Hi, very nice tool indeed!

as I use pdflatex, I've had to change a few lines and use a small trick which might be useful:

first, I change these lines in laprint.m, to uncomment the \documentclass and \begin{document} lines, I add a \thispagestyle{empty} command and I get rid of the \include{file}:

fprintf(fid, ' \\documentclass{article}\\usepackage{');
if color
fprintf(fid, ',psfrag}\n');
fprintf(fid,[ ' \\begin{document}\n\\thispagestyle{empty}\n' ]);
In the end, I had the \end{document} command.
fprintf(fid,[ '\\end{document}\n' ]);

This laprint.m modified file generates both .eps and .tex files, but the latter may now be interpreted by a simple 'latex' command. It generates a .dvi file with all psfrag replacements made, which can be converted in .pdf by eps2pdf command line tool. The following script does all the process for one file:

latex unnamed.tex
dvips -E unnamed
epstool --copy --bbox unnamed.eps
epstopdf unnamed.eps

18 Jan 2006 fe ffe  
20 Nov 2005 Alexander Gahr

Verry Good tool. I love it.

But ...
it uses psfrag wich is not aviable for pdflatex
so i must use latex. I hope to find a good way of including matlab figures with pdflatex.

08 Nov 2005 james buck

Nice one!

27 Oct 2005 Axel Junge

Impressive. I am using psfrag with my figures for a long time already, but was making adjustments by hand. For Matlab figures, this gives the automation I always dreamed of.

25 Aug 2005 Jonathan Sievers

Thank you so much! Wish I had known about it years ago.

06 Jul 2005 John Harrold

I really like this program. I've used it for every paper I've submitted, and now I'm using it for my dissertation. It makes figures very professional looking by providing font consistency throughout a document.

17 Jun 2005 Uli Theune

Now, that's a code I wish I had discovered BEFORE writing my thesis! Very good and very useful!

22 May 2005 Do Wan Kim

Very Very exellent!

21 May 2005 Bülent Yagim

Wie geil ist das denn?

29 Apr 2005 Juha Mäkipelto  
16 Mar 2005 Ho Jae Lee

A definite solution to LaTeX figure with MATLAB!!

28 Feb 2005 Rahul Premraj

Brilliant piece of work. Produces crisp graphics for inclusion in publications. Sometimes not very clever with resizing legends.

03 Dec 2004 Jebbe van der Werf

Great stuff!! I can now finish my PhD in a wonderful way.

10 Nov 2004 Daniel Sandberg

This is definately a useful utility for Matlab. I am going to use this all the time for my work!

08 Nov 2004 Troy Henderson

Awesome utility. Make psfrag super easy!

21 Oct 2004 Francisco Beron-Vera

Wonderful program. By far much more flexible than the LaTeX interpreter in Matlab 7+.

19 Sep 2004 Karsten Quint

I used psfrag manually before. Now LaPrint really eases my work!

18 Aug 2004 Ana Santos  
29 Jul 2004 Kuldeepsinh Rana

Excellent program and a very well written guide to explain even the newbies! It was very useful in writing my thesis.

03 Jul 2004 Devon Yates

A really well put together program. I have struggled to make my matlab figures look decent with matlab, and Laprint makes them look great.

21 Jun 2004 Daniel Czarkowski  
12 May 2004 Daniel Czarkowski

Well, I strongly recomend to update from version 2.03 (19.1.2000) to 3.15

26 Mar 2004 Kostas Kakoyiannis

Nice job Arno! Working with figures can be really disappointing for novice LaTeX users, but all that can change now if you're a MATLAB afficionado as well.

22 Mar 2004

Update of www-references

29 Apr 2004

enhanced ticklabel alignment, bugs removed

30 Apr 2004

handling axes without ticks

Contact us