Setting axis label with both LaTeX and text

조회 수: 92 (최근 30일)
MathWorks Support Team
MathWorks Support Team 2021년 1월 22일
답변: MathWorks Support Team 2021년 2월 25일
I would like to set the axis label of a plot with the following text: "Distance (\lambda)"However, if I use:
>>xlabel('Distance (\lambda)')
the symbol is not identified. If I add a LaTeX interpreter, everything is treated as LaTeX. How do I achieve the desired formatting?

채택된 답변

MathWorks Support Team
MathWorks Support Team 2021년 1월 22일
The symbol '\lambda' is not identified because it is not in a LaTeX interpreter. MATLAB only supports LaTeX markup when the interpreter property is set to 'latex.' You can use dollar symbols around the text if you want everything to be interpreted as LaTeX, but if you want to have both text and LaTeX in the same line, you need to separate the two parts into an array.
For example, in this specific case, you could use the line:
>>xlabel(['Distance ','$(\lambda)$'],'interpreter','latex')
By separating the text and LaTeX expressions in a char array, you can obtain the desired result. 

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Labels and Annotations에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by