LaTeX - Maple Help

 LaTeX

 • The latex command has been rewritten for Maple 2021, and it can now translate to LaTeX everything that can be displayed on a Maple worksheet or document (not embedded components) . The File > Export As > LaTeX related functionality has also been rewritten, now resulting in a LaTeX file that contains equation labels, hyperlinked in the input and text when they appear as such in the worksheet being exported, and where the input and output in the LaTeX file are formatted using automatic line breaking.
 • There are now three main ways of using latex.
 – Entering $\mathrm{latex}\left(\mathrm{expression}\right)$ followed by pressing Enter produces the display on the screen of the LaTeX form of expression, that you can copy and paste into a .tex file, to be used with any LaTeX application (not provided with the Maple system).
 – Any Maple expression being displayed, input or output, or a subexpression of it, can be highlighted with the mouse, then translated to LaTeX and copied in one go through right-click and using the menu Edit > Copy As > Copy as LaTeX.
 – Any Maple worksheet, say filename.mw, can be translated to LaTeX as a whole using the menu File > Export As > LaTeX. The resulting file, filename.tex, can be processed with any LaTeX application to produce a PDF file that looks as the worksheet. For tips to improve the LaTeX translation see LaTeX:-Tips.
 • You can now use File > Export As > LaTeX to produce LaTeX versions of course lessons or entire scientific papers directly in the Maple worksheet, that combines what-you-see-is-what-you-get editing capabilities, including equation labels and all the sophisticated Maple Typesetting available, with the Maple computational engine to produce mathematical results.

The latex:-Settings

 • Several settings of the translation to LaTeX can now be adjusted according to preference, using the $\mathrm{latex}:-\mathrm{Settings}$ command or its synonym $\mathrm{LaTeX}:-\mathrm{Settings}$. These settings and the corresponding default values can be seen entering the command with no arguments or using the keyword query
 > $\mathrm{latex}:-\mathrm{Settings}\left(\right)$
 $\left[{\mathrm{cacheresults}}{=}{\mathrm{true}}{,}{\mathrm{commabetweentensorindices}}{=}{\mathrm{false}}{,}{\mathrm{invisibletimes}}{=}{""}{,}{\mathrm{leavespaceafterfunctionname}}{=}{\mathrm{false}}{,}{\mathrm{linelength}}{=}{66}{,}{\mathrm{powersoftrigonometricfunctions}}{=}{\mathrm{mixed}}{,}{\mathrm{spaceaftersqrt}}{=}{\mathrm{true}}{,}{\mathrm{usecolor}}{=}{\mathrm{true}}{,}{\mathrm{usedisplaystyleinput}}{=}{\mathrm{true}}{,}{\mathrm{useimaginaryunit}}{=}{I}{,}{\mathrm{useinputlineprompt}}{=}{\mathrm{true}}{,}{\mathrm{userestrictedtypesetting}}{=}{\mathrm{false}}{,}{\mathrm{usespecialfunctionrules}}{=}{\mathrm{true}}{,}{\mathrm{usetypesettingcurrentsettings}}{=}{\mathrm{false}}\right]$ (1.1)
 • The possible values of the right-hand sides and their meaning is as follows
 – cacheresults : all results by the internal latex subroutines are cached, for performance, so the translations are computed only once. However, if you are changing things in your worksheet that affect the way things are displayed, previously cached results may prevent you to get different LaTeX translations for the same input. To avoid caching results pass $\mathrm{cacheresults}=\mathrm{false}$. Alternatively, use the latex option forget, or the command $\mathrm{latex}:-\mathrm{Forget}\left(\right)$.
 – commabetweentensorindices : default value is false; if set to true, a comma between tensor indices is placed also in the LaTeX translation, so that they are displayed the same way they are on a Maple sheet.
 – invisibletimes : sets the string used to represent the product operator, by default " ". That matches the default of the LaTeX typesetting system where no spacing is placed between the operands of a product, so a*b is displayed $\mathrm{ab}$. To have a small space between the operands of a product you can use $\mathrm{invisibletimes}="\\,"$
 – leavespaceafterfunctionname : default value is false; if set to true no \! LaTeX negative spacing command will be placed between a function name, say $F$ and the large parenthesis \left( \right) surrounding the function's arguments.
 – linelength : default value is 66; it indicates the approximate length at which a line-break $"\\"$ should be introduced when using the option breaklines.
 – powersoftrigonometricfunctions : default value is mixed; other possible values are textbooknotation and computernotation. With the value mixed, ${\mathrm{sin}\left(x+y\right)}^{2}$ is translated to LaTeX as \sin^2 (x + y), and upon compilation will look like ${\mathrm{sin}}^{2}\left(x+y\right)$. With the value textbook, in addition, inverse trigonometric functions are translated to LaTeX with the notation that uses the name of the corresponding trigonometric function power -1, so $\mathrm{arcsin}\left(x+y\right)$ is translated as \sin^{-1} (x + y). With the value computer the translation is an exact replica of what you see displayed on the Maple sheet.
 – spaceaftersqrt : default value is true; to insert or not a LaTeX small spacing command after a square root when it is an operand of a product.
 – usecolor : default value is true, so that colors in the worksheet are translated as such to LaTeX.
 – usedisplaystyleinput : default value is true, so that when using File > Export As > LaTeX all the input lines appears preceded by \displaystyle, i.e.: when compiling the .tex file, these lines are displayed with LaTeX math display style (the size of the fonts won't depend on the context).
 – useimaginaryunit : default value is the one shown by $\mathrm{interface}\left(\mathrm{imaginaryunit}\right)$, that in Maple is the capital letter I. This setting can be used to indicate the use of a different symbol when translating to LaTeX.
 – useinputlineprompt : can be true or false, to put or not a prompt at the beginning of Maple input lines when using File > Export As > LaTeX. When the Maple sheet was created as a worksheet, $\mathrm{interface}\left(\mathrm{format}\right)="worksheet"$ and so the default value of useinputlineprompt is true. Otherwise, when it started as a document, $\mathrm{interface}\left(\mathrm{format}\right)="document"$ and the value of useinputlineprompt is by default false. You can use useinputlineprompt to override these default values.
 – userestrictedtypesetting : default value is false; if set to true, only a restricted form of typesetting, like the one used in the input lines of the Maple help pages, is used when translating to LaTeX.
 – usespecialfunctionrules : default value is true; if set to false, no typesetting for the notation of mathematical is used.
 – usetypesettingcurrentsettings : default is false; if set to true the Typesetting rules set in the Maple worksheet are not overridden by latex.

Tips for File > Export As > LaTeX

 • The section latex:-Tips present several recommendations to get an optimal translation when exporting Maple sheets using File > Export As > LaTeX. Among the most relevant ones:
 – In the worksheet, before exporting, remove all or selectively some of Maple's input, while keeping all of Maple's output and corresponding equation labels, by respectively using the menus View > Show/Hide Contents > Input or Edit > Delete Element. This is particularly useful to produce LaTeX mathematical documents that entirely or partially hide their computer algebra origin.
 – In the worksheet, select any mathematical expression written using Maple syntax that appears within the text (e.g. Int(f(x), x)), or as Maple input and use Format > Convert To > 2-D Math Nonexecutable (or, alternatively, right-click (Command-click, on Mac) and select Convert To > 2-D Math Nonexecutable) to produce a textbook mathematical display of that expression, that will then appear as such in the LaTeX exported document.
 – In the resulting filename.txt file, adjust the new automatic line-breaking of math formulas by placing $\mathrm{\\}$ wherever you want an additional line-break, or enclosing a formula's subexpression between $\left\{\right\}$ to avoid its automatic line-breaking.
 – Set several preferences regarding how to perform the LaTeX translation using the latex:-Settings command. To see the different settings and their current value enter $\mathrm{latex}:-\mathrm{Settings}\left(\right)$.

Examples

Fractions are translated using the \frac LaTeX command, not elevating the denominator to the power -1

 > $\mathrm{ee}≔\frac{a}{x+\frac{y}{3}}$
 ${\mathrm{ee}}{≔}\frac{{a}}{{x}{+}\frac{{y}}{{3}}}$ (3.1)
 > $\mathrm{latex}\left(\mathrm{ee}\right)$
 \frac{a}{x +\frac{y}{3}}

You can use latex or LaTeX indistinctly; these two commands are synonyms of each other.

 > $\mathrm{LaTeX}\left(\mathrm{ee}\right)$
 \frac{a}{x +\frac{y}{3}}

The LaTeX translation is displayed on the screen; that is useful for copy & paste, but the actual return value of latex(ee) is NULL. If you need a non-NULL return value use output = string

 > $\mathrm{latex}\left(\mathrm{ee},\mathrm{output}=\mathrm{string}\right)$
 ${"\frac\left\{a\right\}\left\{x +\frac\left\{y\right\}\left\{3\right\}\right\}"}$ (3.2)

Color is translated the same way you see it on the screen (blue and black are ignored)

 > $\mathrm{ee}≔\left(\mathrm{Int}=\mathrm{int}\right)\left(\frac{1}{{x}^{2}+1},x\right)$
 ${\mathrm{ee}}{≔}{\int }\frac{{1}}{{{x}}^{{2}}{+}{1}}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{ⅆ}{x}{=}{\mathrm{arctan}}{}\left({x}\right)$ (3.3)
 > $\mathrm{latex}\left(\mathrm{ee}\right)$
 \textcolor{gray}{\int}\frac{1}{x^{2}+1}\textcolor{gray}{d}x = \arctan \! \left(x \right)

Translating color is a setting. You can change any of the latex:-Settings using latex:-Settings(keyword = value) or using its synonym LaTeX:-Settings. To query about these settings use the keyword $\mathrm{query}$ or enter the command without arguments

 > $\mathrm{latex}:-\mathrm{Settings}\left(\right)$
 $\left[{\mathrm{cacheresults}}{=}{\mathrm{true}}{,}{\mathrm{commabetweentensorindices}}{=}{\mathrm{false}}{,}{\mathrm{invisibletimes}}{=}{""}{,}{\mathrm{leavespaceafterfunctionname}}{=}{\mathrm{false}}{,}{\mathrm{linelength}}{=}{66}{,}{\mathrm{powersoftrigonometricfunctions}}{=}{\mathrm{mixed}}{,}{\mathrm{spaceaftersqrt}}{=}{\mathrm{true}}{,}{\mathrm{usecolor}}{=}{\mathrm{true}}{,}{\mathrm{usedisplaystyleinput}}{=}{\mathrm{true}}{,}{\mathrm{useimaginaryunit}}{=}{I}{,}{\mathrm{useinputlineprompt}}{=}{\mathrm{true}}{,}{\mathrm{userestrictedtypesetting}}{=}{\mathrm{false}}{,}{\mathrm{usespecialfunctionrules}}{=}{\mathrm{true}}{,}{\mathrm{usetypesettingcurrentsettings}}{=}{\mathrm{false}}\right]$ (3.4)

So, for example, to avoid color being translated, you can enter

 > $\mathrm{latex}:-\mathrm{Settings}\left(\mathrm{usecolor}=\mathrm{false}\right)$
 $\left[{\mathrm{usecolor}}{=}{\mathrm{false}}\right]$ (3.5)
 > $\mathrm{latex}\left(\mathrm{ee}\right)$
 \int \frac{1}{x^{2}+1}d x = \arctan \! \left(x \right)

More varied examples of the interactive use of latex are presented in the Examples section of the latex help page.

Regarding File > Export As > LaTeX, as an illustration of the new exporting capabilities, you can open the worksheet Physics,Examples, use the menu View > Expand All Sections, then the menu File > Export As > LaTeX, and compile the resulting .tex file with any LaTeX app. The resulting PDF file has 86 pages long of LaTeX translated plots, text, input and output with equation labels and sophisticated mathematical notation, showcasing also the new automatic line-breaking of long input and output expressions.