Setting axis label with both LaTeX and text
93 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
MathWorks Support Team
le 22 Jan 2021
Réponse apportée : MathWorks Support Team
le 25 Fév 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?
Réponse acceptée
MathWorks Support Team
le 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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Labels and Annotations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!