Error with LaTeX formatting in figure legend
5 views (last 30 days)
Show older comments
Alexander Muir
on 11 Mar 2018
Commented: Star Strider
on 11 Mar 2018
When using the LaTeX interpreter, the square brackets interfere with the the formatting of the characters within the legend, specifically reverting the subsequent characters after \mu to normal text. In the title, I used $$ to separate the greek letter but this doesn't work with the square brackets. Any help appreciated.
set(0,'defaulttextinterpreter','latex') %set default font to latex
figure
grid on
plot(v,xi1,'-bo',v,chi1,'-.rx',v,psi1,'--kp') % Plot data
legend('\xi [\mum]', '$\xi {[nm]}$','Location','southeast');% Generates legend
xlabel ('Velocity [m/s]', 'fontsize', 12);% Titles x-axis
ylabel ('Metrics [Dimensionless]', 'fontsize', 12);% Titles y-axis
grid on;% Turns grid on
title ('For $\mu$ m-scale Ti', 'fontsize', 14);% Titles plot
Result:

legend('$\xi$ [$\mu$m]', '$\xi$ [nm]','Location','southeast');% Generates legend
set(legend,'Interpreter','latex')
But now I've come across a similar issue... How to set the axes values to LaTeX font?
0 Comments
Accepted Answer
Star Strider
on 11 Mar 2018
See if substituting: \left[ for [ and \right] for ] improves your result. It worked when I experimented with it:
legend('$\xi \left[ \mu m \right]$', '$\xi{\left[ nm \right]}$', 'Location','southeast');% Generates legend
4 Comments
More Answers (0)
See Also
Categories
Find more on Labels and Annotations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!