How to include a character with a macron (horizontal bar) in a legend?

I am trying to put a macron over an "s" in a legend string. I have tried LaTeX syntax, but it does not work. This is my code:
hLegend(3) = legend([h1, h2, h3], ...
'\it{r_{123}}', ...
'| \it{r_{123}} |', ...
'\it{$\bar{s}$_{123}}');
set(hLegend(3), 'interpreter','latex');
And this is the warning I get
Warning: Unable to interpret LaTeX string
"\it{r_{123}}"
Warning: Unable to interpret LaTeX string
"| \it{r_{123}} |"
Warning: Unable to interpret LaTeX string
"\it{$\bar{s}$_{123}}"
Any idea what I could be doing wrong?

 Respuesta aceptada

Workaround as described in NG: Matlab and Latex
plot(1:10)
h = legend('$\bar{s}$');
set(h,'interpreter','Latex','FontSize',18)

5 comentarios

I tried this and it does not work, please see the edit of my question. Thanks :)
You have to include the whole latex statement in between the $$:
hLegend(3) = legend('$\it{r_{123}}$', ...
'$| \it{r_{123}} |$', ...
'$\rm{\bar{s}_{123}}$');
set(hLegend(3), 'interpreter','latex');
Excellent, even though the font changes to LaTex one, it works perfectly. Thanks :)
The thing about the font is a known issue, there are some workarounds on the Newsgroup or on CSSM directly.
Thanks, that works

Iniciar sesión para comentar.

Más respuestas (1)

Complementing Oleg's answer, I include one of the workarounds he suggest.

Categorías

Más información sobre Creating, Deleting, and Querying Graphics Objects en Centro de ayuda y File Exchange.

Preguntada:

el 1 de Sept. de 2011

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by