texlabel
Converts an expression or Greek-letter text to TeX markup for use in labels.
Category: Graphics > Formatting and Annotation
Syntax
s = texlabel(expr)
Returns a character vector in TeX notation for the expression given as text.
Description
Greek letter names such as alpha or beta become \alpha and \beta, and exponents and subscripts are enclosed in braces. The result can be passed to xlabel, title or text, which render TeX by default.
Writing the TeX string directly is usually simpler for short labels. texlabel helps when the expression comes from a variable or a symbolic formula.
Input arguments
expr- Expression as text, such as
'alpha^2'or'sin(alpha)/beta'. Names of Greek letters are turned into TeX commands.
Output arguments
s- Character vector with TeX markup, ready to use with the
'Interpreter', 'tex'setting of labels and titles.
Example
Greek letters and a power
s1 = texlabel('alpha^2')
s2 = texlabel('sin(alpha)/beta')
plot(1:3)
xlabel(s1)
Output
s1 = '{\alpha}^{2}'
s2 = '{sin}({\alpha})/{\beta}'