5

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.

5
  • 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, 2012 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, 2012 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, 2012 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, 2012 at 19:31
  • 1
    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. Feb 3, 2012 at 19:50

4 Answers 4

3

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
#
5

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.

1

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

1

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .