FromLatex - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

MathML

  

FromLatex

  

translate a LaTeX expression into MathML

 

Calling Sequence

Parameters

Description

Examples

Compatibility

Calling Sequence

FromLatex( latexstring )

FromLatex( latexstring, opts )

Parameters

latexstring

-

a LaTeX expression as a string

opts

-

(optional) equation of the form output = o, where o is one of mathml and maple

Description

• 

This command converts a LaTeX expression to MathML, and optionally further processes it into a Maple expression.

• 

By default, the command just converts the string to MathML. To convert the expression to a Maple expression, use the output = maple option. The default is output = mathml. This can be used if MathML is the intended final format, or if you want more control over how the MathML is imported into Maple, as shown in the final example below.

Examples

This example takes a LaTeX expression, converts it to MathML, and then to Maple

L\\cos (2\\theta) = \\cos^2 \\theta - \\sin^2 \\theta:

mmlMathML:-FromLatexL

mml<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow><mi>cos</mi><mo stretchy="false">&#x00028;</mo><mn>2</mn><mi>&#x003B8;</mi><mo stretchy="false">&#x00029;</mo><mo>&#x0003D;</mo><msup><mi>cos</mi><mn>2</mn></msup><mi>&#x003B8;</mi><mo>&#x02212;</mo><msup><mi>sin</mi><mn>2</mn></msup><mi>&#x003B8;</mi></mrow></math>

(1)

MathML:-Importmml&comma;source=calculator

cos2θ=cosθ2sinθ2

(2)

You can achieve the same thing by passing the option output = maple.

MathML:-FromLatexL&comma;output=maple

cos2θ=cosθ2sinθ2

(3)

Remember that backslash is an escape character, n means newline, t means tab, and \ means a backslash.  When inputting expressions in a string, the backslashes will need to be doubled-up.  This is not needed when reading strings from a file.

L\\frac{n!}{k!(n-k)!} = \\binom{n}{k}&colon;

mmlMathML:-FromLatexL&comma;output=maple

mmln!k!nk!=nk

(4)

Here is a nested fraction

L\\frac{\\frac{1}{x}+\\frac{1}{y}}{y-z}&colon;

mmlMathML:-FromLatexL&comma;output=maple

mml1x+1yyz

(5)

If that fraction had numbers instead of variables, the converted expression would simplify. To see the structure, use the output=inert option, with will insert inert operators. Inert operators are prefixed with a % symbol, and don't evaluate.

L\\frac{\\frac{1}{2}+\\frac{1}{3}}{4-5}&colon;

mmlMathML:-FromLatexL

mml<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow><mfrac><mrow><mfrac><mrow><mn>1</mn></mrow><mrow><mn>2</mn></mrow></mfrac><mo>&#x0002B;</mo><mfrac><mrow><mn>1</mn></mrow><mrow><mn>3</mn></mrow></mfrac></mrow><mrow><mn>4</mn><mo>&#x02212;</mo><mn>5</mn></mrow></mfrac></mrow></math>

(6)

iexMathML:-Importmml&comma;source=calculator&comma;output=inert

iex12+1345

(7)

valueiex

56

(8)

Compatibility

• 

The MathML[FromLatex] command was introduced in Maple 2025.

• 

For more information on Maple 2025 changes, see Updates in Maple 2025.

See Also

latex

MathML

MathML:-Import

MathML[Export]

MathML[ExportContent]

Paste MathML

XMLTools

 


Download Help Document