# Question:Maple generates different latex using Typesetting compared to export latex

## Question:Maple generates different latex using Typesetting compared to export latex

Maple 2021

I only use latex() to convert Maple solution to Latex. I do not export whole document to Latex.

When I ask Maple to convert this solution of a PDE to latex, it generated strange Latex which is different, from the Latex it generates for same solution, when doing File->Export As->Latex.

The Latex it generated in the export case, is the one I want. The latex it generates from the latex() command, I am not able to use and is completely different. It has things like \mathit{Typesetting} and other different latex.

Why is that? And how to make it generates the same Latex for this expression as in the export case?

First I show screen shot, then the worksheet to reproduce it

But Now when I save this worksheet (with only the expression I want)

Using File->Export As->Latex, and then look at the latex for the "sol" in the latex file generated, this is what it shows (I am only showing the latex part of the above, not the whole file)

\begin{maplelatex}
\mapleinline{inert}{2d}{}
{$\mathit{sol} \coloneqq u \left(r ,t \right)=\mathcal{L}^{-1} \left(\frac{\mathrm{BesselJ}\left(0,10 \sqrt{-s}\, r \right) s} {\mathrm{BesselJ}\left(0,20 \sqrt{-s}\right) \left(s^{2}+1\right)},s ,t \right) -\mathcal{L}^{-1}\left(\frac{\mathrm{BesselJ}\left(0,10 \sqrt{-s}\, r \right)} {\mathrm{BesselJ}\left(0,20 \sqrt{-s}\right) s},s ,t \right) -\cos \left(t \right)+1$}
\end{maplelatex}

The above latex I can compile standalone, and it does not have the problematic constructs found when using latex(sol)

One can see it is very different from the top one given earlier.

Why are the two latex different? Is there an extra setting one needs to adjust?  How make latex(sol) generate the same latex for the expression as found in the file generated by export as latex?

may_2.mw

update 1

Did some debugging. The problem happens when using :-executeprintroutines.  Tracing the latex() command in the debugger. At lines 42, it has the call

texlist := [latex:-Print(e,_rest,':-executeprintroutines',':- handleimaginaryunit',':-performonlyoncetasks',opt)];

Where above is the expression to convert to Latex. When I removed ':-executeprintroutines' the problems in latex went away. Here is an example

restart;
sol:=u(r,t) = invlaplace(BesselJ(0,10*(-s)^(1/2)*r)/BesselJ(0,20*(-s)^(1/2))*s/(s^2+1),s, t) - invlaplace(BesselJ(0,10*(-s)^(1/2)*r)/BesselJ(0,20*(-s)^(1/2))/s,s, t)- cos(t) + 1;
latex:-Print(sol)


Gives

"u ! left(r , t\right)",  = , \\mathit{invlaplace}
\\! \\left(\\frac{\\mathit{BesselJ}\\! \\left(0, 10 \\sqrt{-s}\\, r \\right) s}
{\\mathit{BesselJ}\\! \\left(0, 20 \\sqrt{-s}\\right) \\left(s^{2}+1\\right)}, s , t\\right)
-\\mathit{invlaplace} \\! \\left(\\frac{\\mathit{BesselJ}\\!
\\left(0, 10 \\sqrt{-s}\\, r \\right)}{\\mathit{BesselJ}\\! \\left(0, 20 \\sqrt{-s}\\right) s}, s , t\\right)
-\\cos \\! \\left(t \\right)+1

Now notice what happens when adding ':-executeprintroutines'

restart;
sol:=u(r,t) = invlaplace(BesselJ(0,10*(-s)^(1/2)*r)/BesselJ(0,20*(-s)^(1/2))*s/(s^2+1),s, t) - invlaplace(BesselJ(0,10*(-s)^(1/2)*r)/BesselJ(0,20*(-s)^(1/2))/s,s, t)- cos(t) + 1;
latex:-Print(sol,':-executeprintroutines')


it gives the problematic latex

"u ! left(r , t\right)",  = , \\mathit{Typesetting}\\mcoloneq \\mathit{msup}\\!
\\left(\\mathit{Typesetting}\\mcoloneq \\mathit{mi}\\!
\\left(\\text{\\$\\mathcal\\{L\\}$"}\\right), \\mathit{Typesetting}\\mcoloneq
\\mathit{mrow}\\! \\left(\\mathit{Typesetting}\\mcoloneq \\mathit{mo}\\!
\\left(\\text{\\$-$"}\\right), \\mathit{Typesetting}\\mcoloneq \\mathit{mn}\\!
\\left(\\1"\\right)\\right), \\mathit{Typesetting}\\mcoloneq \\mathit{msemantics}=\\text{\\atomic"}\\right)\\! \\left(\\frac{J_{0}\\! \\left(10
\\sqrt{-s}\\, r \\right) s}{J_{0}\\! \\left(20 \\sqrt{-s}\\right) \\left(s^{2}+1\\right)}, s , t\\right)-
\\mathit{Typesetting}\\mcoloneq \\mathit{msup}\\! \\left(\\mathit{Typesetting}\\mcoloneq
\\mathit{mi}\\! \\left(\\text{\\$\\mathcal\\{L\\}$"}\\right), \\mathit{Typesetting}\\mcoloneq
\\mathit{mrow}\\! \\left(\\mathit{Typesetting}\\mcoloneq \\mathit{mo}\\! \\left(\\text{\\$-$"}\\right),
\\mathit{Typesetting}\\mcoloneq \\mathit{mn}\\! \\left(\\1"\\right)\\right),
\\mathit{Typesetting}\\mcoloneq \\mathit{msemantics}=
\\text{\\atomic"}\\right)\\! \\left(\\frac{J_{0}\\! \\left(10 \\sqrt{-s}\\, r \\right)}
{J_{0}\\! \\left(20 \\sqrt{-s}\\right) s}, s , t\\right)-\\cos \\! \\left(t \\right)+1

I do not know what :-executeprintroutines does and how one can tell latex() not to call it at the user level. I asked about :-executeprintroutines before here

And I could not find any documenation on it.

I tried to define my own executeprintroutines proc() which does nothing. But it did not help

restart;
sol:=u(r,t) = invlaplace(BesselJ(0,10*(-s)^(1/2)*r)/BesselJ(0,20*(-s)^(1/2))*s/(s^2+1),s, t) - invlaplace(BesselJ(0,10*(-s)^(1/2)*r)/BesselJ(0,20*(-s)^(1/2))/s,s, t)- cos(t) + 1;
executeprintroutines:=proc()
NULL;
end proc;
latex(sol)


The Latex was not fixed. It is same.

May be the above will help find the issue.

﻿