필터 지우기
필터 지우기

The legend option called interpreter latex does not display the latex symbols correctly

조회 수: 8 (최근 30일)
If I use Interpreter latex in the legend, the latex text is not correctly displayed
plot(1:10,1:10,'DisplayName','\eta_i')
line(1:10,5./((1:10).^2),'color','red','DisplayName','A_{[1,2)}');
legend('Interpreter','latex')
Warning: Error updating Legend.

String scalar or character vector must have valid interpreter syntax:
A_{[1,2)}
Instead, if I do not call Interpreter latex in the legend, the latex symbols are correctly interpreted. Why? I would expect the opposite...
plot(1:10,1:10,'DisplayName','\eta_i')
line(1:10,5./((1:10).^2),'color','red','DisplayName','A_{[1,2)}');
legend

채택된 답변

Star Strider
Star Strider 2024년 2월 20일
You need to put dollar signs ($) around the string you send to the LaTeX interpreter —
plot(1:10,1:10,'DisplayName','$\eta_i$')
line(1:10,5./((1:10).^2),'color','red','DisplayName','$A_{[1,2)}$');
legend('Interpreter','latex')
That also explains the error that was thrown.
.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Legend에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by