In article <gus1va$88s$1@fred.mathworks.com>, "Rivo " <sunny@night.com>
wrote:
> vedenev <vedenev.maxim@gmail.com> wrote in message
> <77c5450314fe49f083ce786066009cdb@p23g2000prp.googlegroups.com>...
> > Default interpreter is 'TeX', to make small phi use \phi:
> > plot([1 2],[3 4]);
> > legend('\phi')
> >
> > you can change interpreter to latex:
> > hl=legend('\phi')
> > set(hl,'Interpreter','latex');
>
> Hi, all
>
> But is there a complete support of latex interpreter in Matlab ? Because, if
> it works fine with the title command, the legend command is really painful to
> use as it doesn't undersatnd the Interpreter property.
>
> What I want to do is to have a legend whose text is built on the fly :
>
> plot([1 2],[3 4], [1 2], [2.5 4.5]);
>
> a= 20.50;
> leg1= sprintf('$$\varphi$$= %g %%', a); % I also tried strcat but same
> problem.
> con=legend(leg1, '$\varphi$ ');
> set(con,'Interpreter','latex');
>
> Result : Matlab chokes on the leg1 string with the following warning:
> Warning: Unable to interpret TeX string
You have a couple of problems. I'm not sure what you want for the text
of your legend, but in any case you didn't escape the \ in sprintf and
you need to escape the % for latex. Assuming you want your legend to
read
o = 20.5%
(substitute \varphi for o) then here's how to do it:
a = 20.5;
str = sprintf('$$\\varphi = %g$$\\%%',20.5);
lh = legend(str);
set(lh,'Interpreter','latex')

Doug Schwarz
dmschwarz&ieee,org
Make obvious changes to get real email address.
