LaPrint
LaPrint prints a MATLAB figure to file for neat inclusion in LaTeX documents.
Author: Arno Linnemann
I solved the ypower-text issue by adding the folowing lines after line 1563:
set(0,'CurrentFigure',figno)
set(figno,'CurrentAxes',hax(i))
It ensures that the power text is actually printed to the intended axes of the intended figure.
Thanks for this function, it is very helpful.
I have added a feature to adjust the legend width when using math code. The math code takes a lot of space which makes the legend too wide. With this feature you can add placeholder text delimited by @...@ in a legend line. This isn't printed in the eps, but it is used to size the legend. This gives correct legend box widths. The modified file is included with the latest update of plot2eps, which uses plotepstex and laprint and further streamlines the work flow.
Also, I found legend2latex to do a better job of converting the legends than plot2eps. See my comment in the File Exchange page for legend2latex for info on how to get it to work with plot2eps (and plotepstex).
Finally, at line 192 I added
fprintf(fid,'\\usepackage{siunitx}\n');
since I often want to include units in my axis labels and siunitx is my preferred package for rendering units with LaTeX.
Already, I can envision wanting other packages or new commands available for use in the axis labels or legends in order to maintain continuity with the rest of my document. I suppose this is why Arno chose to provide the .tex and .eps files separately in his original LaPrint.m, since LaTeX will interpret everything correctly only if you include the figure.tex file in your document.tex file.
For example, I have defined a new command called \conc:
\newcommand{\conc}[1]{[#1]}
If I want to write \conc{K} in the xlabel of my matlab plot and have LaTeX properly interpret it, then I have to either add that \newcommand call into the plotepstex (or laprint) code so that it is present in every new .tex file that plotepstex (or laprint) makes, or I have to use the \include function in my main latex file and I don't end up with an eps file of the figure in which the properly interpreted labels have replaced the psfrags.
After thinking about it for a minute I haven't come up with a nice clean solution for getting this final eps without having to manually add necessary commands or packages to .tex file that laprint normally generates. Anyone have any ideas?
20 Nov 2009
plot2eps
Function to streamline the workflow of converting plots to eps files for inclusion in LaTeX.
Author: Mark Verveld
Very nice work thanks a lot. It saves a lot of work !!
However, I have some troubles using the @...@ text.
Could you put a simple example to illustrate the method.
On my side I have the following line:
$x_{\text{ter}}$ @xter@
At the end, the legendbox is still too large. I do not understand where is my mistake. For information, I use the MATLAB Version 7.8.0.347 (R2009a).
Thanks in advance.
22 May 2009
plot2eps
Function to streamline the workflow of converting plots to eps files for inclusion in LaTeX.
Author: Mark Verveld
Nice work, thanks.
Now I can call one function in my script file to process all the plots and have them saved in the folder where my latex document is.
If something is changed in my results, I only have to run the script and compile my latex and voila I'm done.
Really saves a lot of work!
I did get an error when trying the @...@ text, but it was without having a $...$ mathcode in the string, so you can only use them together.
legend2latex fixes the legend problem without the need for @...@. See my comment on the legend2latex File Exchange page for info on how to incorporate it into plotepstex.
3
22 Mar 2010
plot2eps
Function to streamline the workflow of converting plots to eps files for inclusion in LaTeX.
I haven't tested this extensively, but I've come across the following bugs/issues:
The batch file doesn't work with file names that contain spaces.
To fix this, add double quotes around the eps filename on line 272 so that it reads:
fprintf(fid, 'epstopdf.exe "%s.eps"\n', filename{1,index});
Also, I found legend2latex to do a better job of converting the legends than plot2eps. See my comment in the File Exchange page for legend2latex for info on how to get it to work with plot2eps (and plotepstex).
Finally, at line 192 I added
fprintf(fid,'\\usepackage{siunitx}\n');
since I often want to include units in my axis labels and siunitx is my preferred package for rendering units with LaTeX.
Already, I can envision wanting other packages or new commands available for use in the axis labels or legends in order to maintain continuity with the rest of my document. I suppose this is why Arno chose to provide the .tex and .eps files separately in his original LaPrint.m, since LaTeX will interpret everything correctly only if you include the figure.tex file in your document.tex file.
For example, I have defined a new command called \conc:
\newcommand{\conc}[1]{[#1]}
If I want to write \conc{K} in the xlabel of my matlab plot and have LaTeX properly interpret it, then I have to either add that \newcommand call into the plotepstex (or laprint) code so that it is present in every new .tex file that plotepstex (or laprint) makes, or I have to use the \include function in my main latex file and I don't end up with an eps file of the figure in which the properly interpreted labels have replaced the psfrags.
After thinking about it for a minute I haven't come up with a nice clean solution for getting this final eps without having to manually add necessary commands or packages to .tex file that laprint normally generates. Anyone have any ideas?
4
05 Jan 2010
PlotEpsTeX
eps file exportation with LaTeX text and symbols
Comment only