Setting axis label with both LaTeX and text
93 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
MathWorks Support Team
am 22 Jan. 2021
Beantwortet: MathWorks Support Team
am 25 Feb. 2021
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?
Akzeptierte Antwort
MathWorks Support Team
am 22 Jan. 2021
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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Labels and Annotations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!