LaTeX rendering#
Typeset an expression#
tex(expression) typesets source without evaluating it. tex(expression, true) evaluates first. toTex returns LaTeX as text, and latex renders a quoted LaTeX string.
tex((a + b)^2)
tex(sqrt(16), true)Interactive examples could not load. You can still copy the expressions.
tex(x^2+1)
tex(2+3,true)
toTex(x^2+1)
latex("\\int_0^1 x\\,dx")Interactive examples could not load. You can still copy the expressions.
Backslashes and quoting#
Use a doubled backslash for each LaTeX command inside a math-cell or REPL string passed to latex. Use four backslashes for a matrix row separator (two in the resulting LaTeX). Existing escaped pairs and escaped quotes are preserved; legacy single-backslash commands in math cells are also accepted. tex(...) takes the expression itself, so write tex(x^2+1) unquoted. Quoting it re-escapes the string and the result renders as literal text.
Adding true evaluates first, so that form needs a numeric expression: tex(2+3,true) works, while tex(x^2+1,true) fails because a bare x is undefined.
Markdown inline and display math take raw LaTeX with single backslashes instead. See Writing Markdown.
Results and preferences#
Typeset Math Results controls ordinary results, while an explicit tex or latex call asks for formula rendering directly. Show Raw Below Typeset adds a plain-value line where one is available.
A typeset expression is a display result. It is not a new function and not a numeric variable. Unsupported LaTeX may show an error or fall back to source, so simplify the formula and check the supported renderer syntax.