I have written a module based Maple expressions to LaTeX converter which can handle the following nested (as given by ToInert) inert types:

_Inert_RATIONAL, _Inert_COMPLEX, _Inert_NAME, _Inert_SUM, _Inert_PROD, _Inert_POWER, _Inert_SET, _Inert_LIST, _Inert_FUNCTION, _Inert_MATRIX, _Inert_VECTOR_COLUMN, _Inert_VECTOR_ROW, _Inert_TABLEREF.

As a somewhat cruel test example consider

expr := Matrix(2,2,(i,j) ->
	-(-x)^(-i/2+c)*sin(x)^(-j)*(a+I*b)^((i-j)/2)
	+f({-i,j})/g([-i,j])
	+m[i,j]
);
newLatex:-Latex(expr);

which yields

\left[ \begin{array}{cc} -\frac{\left( -x \right)^{-1/2+c}}{\sin\left( x\right )}+\frac{f \left( \left\{ -1,1 \right\} \right)}{g \left( \left[ -1,1 \right] \right)}+m_{1,1} & -\frac{\left( -x \right)^{-1/2+c}}{\sin\left( x\right )^{2}\sqrt{a+\mathrm{i}b}}+\frac{f \left( \left\{ -1,2 \right\} \right)}{g \left( \left[ -1,2 \right] \right)}+m_{1,2} \\ -\frac{\left( -x \right)^{-1+c}\sqrt{a+\mathrm{i}b}}{\sin\left( x\right )}+\frac{f \left( \left\{ -2,1 \right\} \right)}{g \left( \left[ -2,1 \right] \right)}+m_{2,1} & -\frac{\left( -x \right)^{-1+c}}{\sin\left( x\right )^{2}}+\frac{f \left( \left\{ -2,2 \right\} \right)}{g \left( \left[ -2,2 \right] \right)}+m_{2,2} \end{array} \right]

which appropiately copy-pasted to Scientific WorkPlace, for instance, and subsequently converted to PDF comes out just right. Please feel free to download and test the module, the appropiate links being: View 1808_newLatex.mw on MapleNet or Download 1808_newLatex.mw.

The output can be tweaked in the following ways:

  • The LaTeX string for the complex unit: This is controlled by the local variable COMPLEX_UNIT, which can be accessed/changed using newLatex:-complexUnit without/with a string as argument.
  • Negative powers as fractions: This is controlled by the local variable NEG_POWER_AS_FRACTION, which can be accessed/changed using newLatex:-negPowerAsFraction without/with a boolean as argument.
  • Flatten numerical fractions, i.e., write them as a/b: This is controlled by the local variable NUM_FRACTION_FLATTEN, which can be accessed/changed using newLatex:-numFractionFlatten without/with a boolean as argument.

PS: I am quite aware, of course, that Maple itself has a builtin Maple to LaTeX converter, named latex. However, as earlier noted by JacquesC this converter introduces some "...hard-coded spacing and font changes..." which is not strict LaTeX. My converter introduces no such things.


Please Wait...