functions - Maple Help

How latex Formats Functions

Description

 • When latex processes a Maple object of type function (i.e., an unevaluated function call), it checks to see if there exists a procedure by the name of latex/function_name, where function_name is the name of the function.  If such a procedure exists, it is used to format the function call.
 • For instance, invoking latex(Int(exp(x), x=1..3)) causes latex to check to see if there is a procedure by the name of latex/Int. If such a procedure exists (not the case, but as an example), the above call to latex returns the result of latex/Int(exp(x), x=1..3) as its value.  This allows LaTeX to produce standard mathematical output in most situations.
 • If such a procedure does not exist, latex formats the function call by recursively formatting the operands to the function call and inserting parentheses and commas at the appropriate points.
 • Since Maple 2021, there are no more pre-defined latex/ functions for anything. Instead, the latex command translates what the Maple Typesetting package produces as display. In this way everything you see on the screen can be translated to LaTeX as you see it; for details about that see latex.

Examples

Although latex produces a LaTeX version of the Bessel function of the first kind, BesselJ, and of the hypergeometric function based on the display for them by the Typesetting package, as an exercise consider a latex/BesselJ and latex/hypergeom routines to produce their mathematical notation. For BesselJ,latex/BesselJ would need to produce ${J}_{n}\left(z\right)$. This is how you can achieve that:

 > latex/BesselJ := proc(a,z)     sprintf("{ {\\rm J}_{%s}(%s) }",cat("", latex(a, output = string)), cat("", latex(z, output = string))) end proc:

With this procedure, the translation is:

 > $\mathrm{latex}\left(\mathrm{BesselJ}\left(n,z+1\right)\right)$
 { {\rm J}_{n}(z +1) }

A more sophisticated procedure, for the hypergeometric function pFq:

 > latex/hypergeom := proc(A0, B0, z0) local nA, nB, pFq, p, q, A, B, z;     nA, nB := nops(A0), nops(B0);     pFq := cat('\\mbox{$_',nA,'$F$_',nB,'$}');     if nA = 0 then A, nA := [\\ ], 1 else A := map(u -> latex(u, output = string), A0) end if;     if nB = 0 then B, nB := [\\ ], 1 else B := map(u -> latex(u, output = string), B0) end if;     z := latex(z0, output = string);     p := op(map(u -> (u, ','), A[1 .. -2])), A[-1];     q := op(map(u -> (u, ','), B[1 .. -2])), B[-1];     cat({, pFq, (, p, ;\\,, q, ;\\,, z, )}) end proc:

With this procedure, the translation of the three 2F1, 1F1, and 0F1 functions is as follows.

 > $\mathrm{latex}\left(\mathrm{hypergeom}\left(\left[a,b\right],\left[c\right],z\right)\right)$
 {\mbox{$_2$F$_1$}(a,b;\,c;\,z)}
 > $\mathrm{latex}\left(\mathrm{hypergeom}\left(\left[a\right],\left[c\right],z\right)\right)$
 {\mbox{$_1$F$_1$}(a;\,c;\,z)}
 > $\mathrm{latex}\left(\mathrm{hypergeom}\left(\left[\right],\left[c\right],z\right)\right)$
 {\mbox{$_0$F$_1$}(\ ;\,c;\,z)}