MATLAB Answers


TeX (LaTeX math mode) symbols in legends and labels in MATLAB figures

Asked by Shah
on 22 Nov 2011
Latest activity Edited by Matthew Simoneau on 30 May 2014

I am plotting some data which includes estimates of some parameters. I want to describe the estimates by using \hat on the parameter symbols. This I have o do in legends and axis labels fields. I could not fix this matter despite some experiments using information from MATLAB help. Any idea, please to fix this problem.

I really appreciate help on this matter which will improve the look of my presentation.





No products are associated with this question.

4 Answers

Answer by Frederik van der Walt on 4 Apr 2012

l= legend(['$\hat{\psi}$']);



Answer by Steven
on 22 Nov 2011

Try with Latex interpreter, something like

    title(['$ latex $'],'interpreter','latex')

  1 Comment

on 22 Nov 2011

Thanks Steven but its not working here. I am using MATLAB 7.9.0.

I wrote legend(['$\hat{\psi}$'],'interpreter','latex') but got a warning: Unable to interpret TeX string '$\hat{\psi}$'interpreterlatex'. Same appear in the legend field.

Answer by Shah
on 23 Nov 2011

......... Its done! Actually, the default interpreter in MATLAB for legend is 'tex', I guess. It is not changed from the code line. What I had to do was to right click on the legend in the figure window and then changed the 'interpreter' from 'tex' to 'latex'. This action changed the latex statement in the legend field to Math mode.

Cheers Shah


Answer by Matthew Simoneau on 30 May 2014

To use the full LaTeX interpreter, you can specify it as a parameter:


Note that for legend, you need to use pass in you labels as a cell array to distinguish them from the parameters:



Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply today