File Exchange

image thumbnail


version (3.46 KB) by Ercan Solak
Converts MATLAB figure to a TeX file representation.


Updated 15 Sep 2008

View License

fig2tex is a MATLAB function that produces a LaTeX file to replicate MATLAB figures using PSTricks macros. ( the final LaTeX file requires the PSTricks packages pst-plot and pst-node, in particular).

With fig2tex, you have a LaTeX file that produces your figure in LaTeX + PSTricks. Hence, text style remains uniform throughout your document. Same thing for scaling. Moreover, small changes (like changing the label text) can directly be made on the LaTeX file.

Latest version 0.7, 2005/6/27

Cite As

Ercan Solak (2019). fig2tex (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (3)

This provides a very convenient way to embed Matlab figures into LaTeX. The results look great!

Radu Serban

Great idea! A few problems though:

1) To avoid "Conversion to cell from char is not possible." errors, the concatenation lines of the type
wrstr = [wrstr,linestr];
should be changed to
wrstr = [wrstr,{linestr}];

2) The functions chokes if the figure does not have a legend. It needs a test
if ~isempty(legh)

3) There are several elements that cannot appear in the figure (eg. rectangle, text) since they do not have an 'XData' property. The loop over the children handles should test the 'type' property and act accordingly.

Ismail Demirkan

I tried this, works as promised. Figures look like excellent. You can avoid time consuming task of scaling small fonts in Matlab figures.
Thanks for sharing this.


My institution and the web address changed. Files are the same.

Fixed some bugs and added some features

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