Matlab set defaultTextInterpreter to LaTeX

I am running Matlab R2010A on OS X 10.7.5

I have a simple matlab graph and you want to use LaTeX commands in axis and legend. However setting:

set(0, 'defaultTextInterpreter', 'latex');

It has a null effect and leads to a TeX warning that my tex commands cannot be parsed. If I open the plot tools of this plot, the interpreter will be set to "TeX" by default. Manually installing this in LaTeX is obviously a fix, but I can't do it for hundreds of graphs.

Now, if I get the default interpreter through the Matlab prompt, that is, get(0,'DefaultTextInterpreter')

He says β€œLaTeX”, but again, when I look at the properties of the figure through the plot tool menu, the interpreter remains set to β€œTeX”.

Print completion code:

 figure f = 'somefile.eps' set(0, 'defaultTextInterpreter', 'latex'); ms = 8; fontSize = 18; loglog(p_m_sip, p_fa_sip, 'ko-.', 'LineWidth', 2, 'MarkerSize', ms); hold on; xlabel('$P_{fa}$', 'fontsize', fontSize); ylabel('$P_{m}$', 'fontsize', fontSize); legend('$\textbf{K}_{zz}$', 'Location', 'Best'); set(gca, 'XMinorTick', 'on', 'YMinorTick', 'on', 'YGrid', 'on', 'XGrid', 'on'); print('-depsc2', f); 
+6
source share
1 answer

This works for me (R2011B)

 figure ms = 8; fontSize = 18; xx = 0:.1:1; plot(xx,sin(xx)) xlabel('P_{fa}', 'fontsize', fontSize); %No need for latex explicitly (Tex is enabled by default) ylabel('P_{m}', 'fontsize', fontSize); legend({'$$\textbf{K}_{zz}$$'}, 'interpreter', 'latex','fontsize',fontSize); %Explicit latex %REM: legend needs a cell 

enter image description here

I can change the 'defaultTextInterpreter'

 set(0, 'defaultTextInterpreter', 'latex'); xlabel('$$P_{fa}$$', 'fontsize', fontSize); ylabel('$$P_{m}$$', 'fontsize', fontSize); legend({'$$\textbf{K}_{zz}$$'},'interpreter', 'latex','fontsize',fontSize) 

get the best version

enter image description here

If I remove the 'interpreter', 'latex' from the legend call, I have bad results:

enter image description here

+14
source

All Articles