latex
LaTeX source of a symbolic expression.
Category: Code Generation
Syntax
s = latex(expr)
Returns the LaTeX markup that typesets expr.
Description
latex converts the expression structure into LaTeX commands such as \frac, \sqrt, \sin and {...}^{...}. The text can be pasted into a document, a web page with MathJax or a label with the 'Interpreter', 'latex' option. The output is a plain character vector, so it must be placed inside $...$ by the caller.
Input arguments
expr- Symbolic expression, equation or matrix.
Output arguments
s- Character vector with LaTeX code, without surrounding math delimiters.
Example
Expressions to LaTeX
syms x
latex(x^2/3)
latex(sin(x)^2)
Output
ans = '\frac{{x}^{2}}{3}'
ans = '{\sin\left(x\right)}^{2}'