TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I know that this might be more a detail rather than a serious problem but I've already Googled it like crazy and I can't find the solution.

Is it possible to achieve a MATLAB plot in pdflatex with the correct text properties of the document (namely size and fonts)? I'm able to achieve a polished figure through the matlabfrag and ml2pdf scripts but when I scale the figure width the text gets scaled as well. I'd like something sort of Inkscape PDF+LaTeX option that outputs a .pdf_t file and a .tex file with the text.

share|improve this question
If you can relax the Matlab requirement and do your plots in R, you can plot to TikZ with tikzDevice which gathers font information via system calls to TeX when placing text. – Sharpie Feb 3 '12 at 17:30
You can do many fantastic plots by using the pgfplots package of whose author is also active in here. It's much better if you try to narrow down your question context. What is the data and which tool(MATLAB command) you normally use to plot? – percusse Feb 3 '12 at 17:46
@percusse Hey! Thanks for the suggestion of pgfplots. Usually I just have to plot lines and histograms but I've already used the "surf" command and I might need to do it again. – Anders Feb 3 '12 at 19:27
I've already tried the matlab2tikz script. I successfully created the tikz file but the latex file doesn't gets compiled. Probably because the plot I was testing was a surface. – Anders Feb 3 '12 at 19:31
Ben Hinkle's exportfig script can write a .eps of the graphics and a separate .eps of the text, but that's not quite what you want. And matlab2tikz can produce surfaces, but if the surface has too many points, you can overrun TeX's capacity. – Mike Renfro Feb 3 '12 at 19:50
up vote 1 down vote accepted

Thank you very much for all the help. I managed to find a fitting solution to this problem. I'll post here the solution in case someone else finds it useful. Basically I turned the tedious 2 steps task matlab-inkscape-PdfLateX into one single task. This is accomplished thanks to the plot2svg matlab function and through the inkscape export feature that can be run from the terminal shell or a script. Then I can run the script from Matlab through the ! invoke shell. Below is the script I created

echo "File name?"
read fname
export LD_LIBRARY_PATH=/usr/lib64;
inkscape $fname.svg -z -D --export-pdf=$fname.pdf --export-latex
rm $fname.svg
share|improve this answer

You could consider to use matlab2tikz script to export the figure from matlab into a tikz file that you could easly include in a latex document.

share|improve this answer

Have you tried matlab2pgf? Give it a try. I suggest one should visit matlab central (file exchange) for applications like this.

share|improve this answer

LaPrint takes a MATLAB figure and creates an eps file with place holders for the text and a TeX file which has the text.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.