Setting axis label with both LaTeX and text
93 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
MathWorks Support Team
il 22 Gen 2021
Risposto: MathWorks Support Team
il 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?
Risposta accettata
MathWorks Support Team
il 22 Gen 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 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Labels and Annotations in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!