latex
produces output suitable for LaTeX printing and provides the translation functionality for File -> Export -> LaTeX
Calling Sequence
Parameters
Options
Description
The latex:-Settings
Tips for File > Export As > LaTeX
Examples
Compatibility
latex(expr, options)
LaTeX(expr, options) : LaTeX is a synonym of latex
expr
-
any Maple expression or construction, or a sequence of them
append = ... : the right-hand side can be true or false (default); related to writeto.
asinpreviousreleases = ... : the right-hand side can be true or false (default); if true, the old latex program, of releases previous to Maple 2021, is used.
breaklines : related to linelength, the right-hand side can be true or false (default), to break lines using \\ according to the value of the linelength keyword, that can also be set and is shown via latex:−Settings⁡linelength.
filename = ... : deprecated (superseded by writeto), the right-hand side can be a symbol or a string representing a filename; if passed, output = file is also required.
forget = ... : the right-hand side can be true or false (default); to forget previously cached translations at the time of performing a latex translation.
linelength : related to breaklines, the right-hand side can be any positive number as an estimation of the desired number of characters in a math line. Its default value can be changed and is shown by latex:−Settings⁡linelength.
output = ... : the right-hand side can be the keyword string, to return a string with the latex translation, or file in which case filename = ... is also required (deprecated use, superseded by writeto).
thisisinput = ... : the right-hand side can be true or false (default); when given, some typesetting restrictions apply and a prompt > is included if the Maple MW file was created as a worksheet (see interface,format).
translation = ... : the right-hand side can be full (default), or restricted, in which case significant typesetting restrictions apply: the translation is done as you see in the input of help pages.
writeto = ... : the right-hand side can be screen (default) or any symbol or string representing a filename to which the output will be written; it can be used together with append, to append instead of overwrite a previously existing filename.
All the optional keywords that can have the value true on the right-hand side can be passed just as themselves, not as an equation, representing the value true. For example forget is the same as forget = true. Also, you don't need to use the exact spelling of any of these keywords - any unambiguous portion of them suffices, e.g. previous for asinpreviousreleases.
The latex function produces output on the screen which is a translation to LaTeX of its arguments, and the LaTeX command is a synonym of latex. This 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 (exception made of embedded components and DocumentTools objects).
The Export As > LaTeX related functionality has also been rewritten, now resulting in a LaTeX file where everything you see on the worksheet is translated, 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 three main ways of using latex.
Entering latex(expression) 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 > 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.
Using File > Export As > LaTeX you can 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 with the Maple computational engine to produce mathematical results. Relevant for this purpose, you can:
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 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.tex file, adjust the automatic line-breaking in the formulas by placing \\ wherever you want an additional linebreak, or enclosing a formula's subexpression between to avoid its automatic line-breaking. This provides valuable flexibility to tweak the way the filename.tex LaTeX file is displayed.
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 latex:−Settings⁡.
The translation of mathematical expressions performed by latex precisely respects the form and color you see on the screen with very few exceptions (e.g. the blue in Maple's output is not translated). For example, inert functions are translated using gray color the way it is used to display them in the worksheet. To change this or other default behaviors you can use latex:-Settings; e.g., to avoid using color and have everything translated in black enter latex:−Settings⁡usecolor=false.
Mathematical functions are translated to LaTeX using the notation shown in the NIST Digital Library of Mathematical Functions. To change that see latex:-Settings and latex,functions.
All alias and print/F routines you may define to compactly display expressions or a function F in any particular way, as well as the value of interface⁡imaginaryunit, are taken into account at the time of translating to LaTeX.
It is possible to change or extend the capabilities of latex to translate any function, say F by defining a procedure with the name `latex/F`. The latex command uses this procedure when it encounters a function with name F within the expression(s) being translated. For more information, see latex,functions.
You can use the GraphTheory:-Latex command to generate LaTeX code for graphs constructed with the GraphTheory package.
The latex command displays output on the screen that can be copied and pasted elsewhere; it however returns NULL as the function value. Therefore the ditto commands, % and %%, will not recall the previous latex output. To get output (return value) different from NULL, you can use the optional argument output = string.
Several settings of the translation to LaTeX can be adjusted according to preference, using the latex:-Settings command or its synonym LaTeX:-Settings. These settings and the corresponding default values can be seen by entering the command with no arguments or using the keyword query
latex:-Settings();
breaklines=false,cacheresults=true,commabetweentensorindices=false,copyaslatexinput=false,invisibletimes= ,leavespaceafterfunctionname=false,linelength=66,powersoftrigonometricfunctions=mixed,spaceaftersqrt=true,usedefaultlatexmacros=false,usecolor=true,usedisplaystyleinput=true,useimaginaryunit=I,useinputlineprompt=true,userestrictedtypesetting=false,usespecialfunctionrules=true,usetypesettingcurrentsettings=false
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 cacheresults=false. Alternatively, use the latex option forget, or the command latex:−Forget⁡.
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.
copyaslatexinput : default value is false. So, when you click the Maple menus to perform Edit > Copy As > LaTeX, the operation translates the given the expression as if it is output. If this option is set to true, the translation is performed as if the expression being copied is input. Copying as input sometimes facilitates the automatic line-breaking, because it uses delimiters without augmentation (e.g., (), not \left( ... \right)). On the other hand, it is frequently preferred to copy expressions translated as output since they display better e.g. when the arguments have fractions.
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 ab. To have a small space between the operands of a product you can use 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 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, sin⁡x+y2 is translated to LaTeX as \sin^2 (x + y), and upon compilation will look like sin2x+y. 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 arcsin⁡x+y 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 interface⁡imaginaryunit, 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, interface⁡format=worksheet and so the default value of useinputlineprompt is true. Otherwise, when it started as a document, interface⁡format=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 functions is used.
usetypesettingcurrentsettings : default is false; if set to true the Typesetting rules set in the Maple worksheet are not overridden by latex.
NOTE: unlike the case where you input latex(expression), when translating whole Maple worksheets using File > Export As > LaTeX the design is to export the worksheet to LaTeX reproducing what you see on the screen. So in that case the following settings are ignored: powersoftrigonometricfunctions, useimaginaryunit, userestrictedtypesetting, usespecialfunctionrules and usetypesettingcurrentsettings.
In order to translate everything that can be displayed on a Maple sheet, some CTAN official LaTeX packages are used, listed at the beginning of the exported .tex file. Current LaTeX applications include those packages. Also, a copy of the maple.sty file, found in the etc directory of your Maple installation (kernelopts(mapledir)), should be in the same directory where you placed the .tex file that resulted from File > Export > LaTeX.
Input lines can be entirely or partially omitted in the exported LaTeX document while keeping all the equation labels unchanged by respectively clearing the check box for Show/Hide Contents > Input in the View menu or using the menu Edit > Delete Element.
The Maple sheet input lines appear in the exported TEX file not indented and using the automatic line-breaking of the LaTeX math {$ ... $} environment. The output lines appear using the automatic line-breaking of the dmath environment of the breqn LaTeX package, plus some additional automatic line-breaking performed by Maple routines where necessary beyond the dmath environment. The additional automatic line-breaking performed by Maple routines appears in the exported TEX file as lines whose only contents is \\, and the linelength keyword of the latex:-Settings can control their occurrence. Both input and output lines can be split furthermore by inserting, in the exported file, \\ wherever you want an additional line break.
To avoid an automatically occurring line-break, in the exported TEX file, enclose within {} the parts of an expression you want to be in the same line. Together with the one of the previous paragraph, this mechanism complements the automatic line-breaking, giving you full control of how lines are split in the exported document.
When working with large expressions, neither the automatic line-breaking, nor the breaklines option of latex, will break lines in fractions or across matrix lines (i.e., the number of matrix columns is not altered).
Matrices have an excellent chance of being appropriately exported, provided that they fit within the margins of a page. Note that is not always the case, despite the matrix fitting within the computer screen's margins.
Before exporting, check the menu options View > Markers, View > Sections > Show Section Boundaries and View > Show/Hide Contents > Execution Group Boundaries. That provides visual indicators of where bookmarks, Sections, paragraphs (text), input and output regions start and end. Using the menu Format > Bookmarks you can change bookmarks, relevant in Table Of Contents, and using Edit and its submenus, you can Split or Join execution groups or sections, Delete Elements, and adjust these regions to get the exported TEX file looking as desired.
When inserting non-ASCII characters in the middle of text, for example, by clicking the palettes, place them within inlined math regions. To start such a region, you can press Shift + F5, type or insert the characters, then end with Ctrl + T (Command + T, on Mac) to return to text mode.
When inlining math within the text, make sure you have both opening and matching closing parenthesis (), {} or [], within the math region. That assures their display in the printed exported LaTeX document is optimal and avoids having unmatched opening or closing delimiters.
When closing inlined math, make sure there is a blank text character before any text that follows instead of an inlined math blank character. While in the Maple sheet, these two different blank characters look the same way, that is not the case in the LaTeX exported document where an ending math blank character is not displayed.
Images can conveniently be inserted in the Maple sheet using the menu Insert > Image > From File. These images appear exported in the TEX file using the \includegraphics environment, with the options keepaspectratio and width = ... where the right-hand side has a maximum value of 3.9⁢in regardless of the width of the image. You can adjust the size of the image in the TEX file by changing those two options or using the height = ... option.
Embedded components are not translated - there exist no natural LaTeX commands for them to translate onto. The alternative is to handle the visualized embedded component as an image. For that, you can Either use the menu Edit > Copy As > Image or depending on your OS/software you can take a screen shoot. Then insert this file image in the right position using the menu Insert > Image > From File. The image will appear in the right place in the .tex exported file and you can tweak its appearance as explained in the previous item.
DocumentTools objects like Tabulate, or Tables (not mathematical table objects) inlined within Text are translated only rudimentarily: all their columns centered. Here too, either you can adjust the look of the table directly in the .tex exported file, or transform the table into an image to be handled the same way as an embedded component explained in the previous item.
You can have the integration constants _Cn, appearing in solutions to differential equations, exported to LaTeX as cn by entering (e.g., for n≤10) alias⁡seq⁡ck=_C‖k,k=0..10.
Fractions are translated using the \frac LaTeX command, not elevating the denominator to the power -1
ee≔ax+y3
latex⁡ee
\frac{a}{x +\frac{y}{3}}
You can use latex or LaTeX indistinctly; these two commands are synonyms of each other.
LaTeX⁡ee
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
latex⁡ee,output=string
Color is translated the same way you see it on the screen (blue and black are ignored)
ee≔Int=int⁡1x2+1,x
ee≔∫1x2+1ⅆx=arctan⁡x
\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 query or enter the command without arguments
latex:-Settings⁡
So, for example, to avoid color being translated, you can enter
latex:-Settings⁡usecolor=false
usecolor=false
\int \frac{1}{x^{2}+1}d x = \arctan \! \left(x \right)
To avoid artificial spacing between a function's name and its arguments surrounded by \left( and \right), the latex command places \! in between, as you see above in \arctan \! \left(x \right). To not have this LaTeX spacing command \! automatically inserted, use, for instance
latex:-Settings⁡leavespace=true
* Partial match of 'leavespace' against keyword 'leavespaceafterfunctionname'
leavespaceafterfunctionname=true
\int \frac{1}{x^{2}+1}d x = \arctan \left(x \right)
Powers of trigonometric (not inverse-trigonometric) functions, say sin⁡x+y2, are frequently display in textbooks as sin2x+y and while the computer uses the former notation, latex uses the latter one for trigonometric functions by default
ee≔sin⁡x+y2+arcsin⁡x2
\sin^{2}\left(x +y \right)+\arcsin \left(x \right)^{2}
You can change that too. The options for the right-hand side of powersoftrigonometricfunctions=... are: textbooknotation, computernotation or mixed (default), and you can use any unambiguous portion of the long-keyword powersoftrigonometricfunctions to indicate it. Using powersoftrig=textbook, in addition, inverse-trigonometric functions are LaTeX translated as the corresponding trigonometric functions to the power -1, so arcsin⁡x will look in the LaTeX translation as sin−1x
latex:-Settings⁡powersoftrig=textbook
* Partial match of 'powersoftrig' against keyword 'powersoftrigonometricfunctions'
powersoftrigonometricfunctions=textbooknotation
\sin^{2}\left(x +y \right)+\left(\sin^{-1}\left(x \right)\right)^{2}
Using powersoftrigonometricfunctions=computer, the LaTeX translation is exactly as displayed in (8)
latex:-Settings⁡powersoftrig=computer
powersoftrigonometricfunctions=computernotation
\sin \left(x +y \right)^{2}+\arcsin \left(x \right)^{2}
When a square root is part of a product, the Maple typesetting leaves a small space between the square root and the next product operand, for example:
ee≔sqrt⁡f⁡x⁢g⁡x
ee≔f⁡x⁢g⁡x
To reproduce that spacing, latex places the LaTeX spacing command \, after the square root when within a product
\sqrt{f \left(x \right)}\, g \left(x \right)
To avoid that extra LaTeX spacing use
latex:-Settings⁡spaceaftersqrt=false
spaceaftersqrt=false
\sqrt{f \left(x \right)} g \left(x \right)
The Maple default for representing the imaginary unit is the capital letter I. This is respected by the LaTeX translation
ee≔x+I⁢y
x +\mathrm{I} y
You can however change this default in two different ways. For example, if you prefer i instead of I, you can use interface⁡imaginaryunit=i
interface⁡imaginaryunit=i:
i y +x
The symbol used in the LaTeX translation to represent the imaginary unit, is always displayed when you input
latex:-Settings⁡imaginary
* Partial match of 'imaginary' against keyword 'useimaginaryunit'
useimaginaryunit=ⅈ
This setting actually allows you to use any different symbol than the one set via interface⁡imaginaryunit=.... For example, keep ⅈ for use in the Maple input/output and use j in the translation to LaTeX
latex:-Settings⁡imaginary=j
useimaginaryunit=j
j y +x
By default, latex leaves the invisible times product operator to be defined by the standard LaTeX typesetting system. That is, for example, no LaTeX spacing command between the letters x and y in the product x⁢y. Hence,
latex⁡x⁢y
x y
That corresponds to the invisibletimes setting:
latex:-Settings⁡invisibletimes
invisibletimes=
If however you prefer, for instance, a tiny space LaTeX command between the operands of a product, you can use latex:−Settings⁡invisible=\\,
latex:-Settings⁡invisibletimes=\\,
invisibletimes=\,
x\,y
Regardless of the value of interface⁡typesetting, or of Typesetting:−EnableTypesetRule⁡SpecialFunctionRules, the mathematical functions of the language are translated to LaTeX using the notation shown in the NIST Digital Library of Mathematical Functions. So for example BesselJ(n, z) is translated to LaTeX as J_{n}\! \left(z \right)
latex⁡BesselJ⁡n,z
J_{n}\left(z \right)
Upon LaTeX compilation, that will look like Jn⁡z. You can change this default in two different ways. First, through the usespecialfunctionrules setting, changing its default value true to false
latex:-Settings⁡specialfunctionrules=false
* Partial match of 'specialfunctionrules' against keyword 'usespecialfunctionrules'
usespecialfunctionrules=false
\mathit{BesselJ}\left(n , z\right)
Reset that setting to its default value
latex:-Settings⁡usespecialfunctionrules=true:
Second, with the usetypesettingcurrentsettings keyword, changing its default value false to true
latex:-Settings⁡usetypesettingcurrentsettings=true
usetypesettingcurrentsettings=true
and so, the value of the Typesetting settings is followed by latex:
Typesetting:-DisableTypesetRule⁡Typesetting:-SpecialFunctionRules
∅
latex⁡BesselJ⁡n,z,forget
When changing Typesetting settings in the middle of a Maple session, to discard previously cached results by latex use the option forget (this is not necessary when changing settings using latex:-Settings)
Typesetting:-EnableTypesetRule⁡Typesetting:-SpecialFunctionRules
The latex command was updated in Maple 2021.
See Also
appendto
Export As LaTeX
GraphTheory:-Latex
interface
latex,functions
Printing and Viewing Maple LaTeX Documents
writeto
Download Help Document