3
$\begingroup$

Reported to WRI. CASE:4250134


Update: Thanks for the smaller example by Chip Hurst in comment, it seems it comes down to this simpler example

 TeXForm[Root[1 + 2 # + #^5 &, 1]] 

Which gives in V 12 the following

 \text{NumericalApproximation}\left[\text{Root},,\text{Root} \left[\text{$\#$1}^5+2\text{$\#$1}+1\&,1\right],\right] 

With messages in console

 TeXForm::unspt: TeXForm of TemplateSlotSequence[1,] is not supported. TeXForm::unspt: TeXForm of -0.486389 is not supported. 

Which compiles to in Latex as

Mathematica graphics

While in Version 11.3, same input gives

 \text{Root}\left[\text{$\#$1}^5+2 \text{$\#$1}+1\&,1\right] 

With no warning messages. which compiles to

Mathematica graphics

So it seems Latex output in 11.3 would have been better to keep as is.


Original question

I am seeing some TeXForm errors or new messages in the console in V12 which do not show in V 11.3.

What do these errors mean when calling TeXForm on a result returned from DSolve in version 12? No such errors come out in 11.3

Mathematica graphics

ClearAll[y,x]; ode = -2 x^3 + Log[x] - y[x] + 2 x y'[x] + x^2 y''[x] + x^3 y'''[x] == 0; sol = DSolve[ode, y[x], x]; TeXForm[sol] 

Mathematica graphics

Is this a bug? Or just warning message? Is there a way around it? The full Latex expression is too long to show.

btw, I am able to compile the latex generated in Tex Live. So I am not sure what these messages mean. The first part of the output compiles to

Mathematica graphics

The rest goes over the edge of page since it is too long.

$\endgroup$
6
  • 1
    $\begingroup$ Seems that TeXForm isn't playing nicely with Root objects. For example try TeXForm[Root[1 + 2# + #^5&, 1]]. $\endgroup$ Commented Apr 22, 2019 at 11:51
  • $\begingroup$ What do you want the TeXForm of a Root object to be? $\endgroup$ Commented Apr 22, 2019 at 14:52
  • $\begingroup$ @CarlWoll may be if it was kept as it worked in version 11.3 would be OK. $\endgroup$ Commented Apr 22, 2019 at 15:37
  • $\begingroup$ Root objects are new in 12, but it looks like they were not implemented in TeXForm. Have you reported this to support? $\endgroup$ Commented Apr 22, 2019 at 16:14
  • 1
    $\begingroup$ Root objects are not new, nor have they changed, as a language feature, in V12. All that has changed is how they are displayed. So the information on the reference page is quite correct $\endgroup$ Commented Apr 23, 2019 at 7:06

2 Answers 2

2
$\begingroup$

Assuming you never want to try to create TeX of the new numerical approximations output, you could do:

Unprotect[Convert`TeX`ExpressionToTeX]; Convert`TeX`ExpressionToTeX[expr_, o___?OptionQ] /; !TrueQ@$TeX := Block[ {$TeX=True, BoxForm`UseApproximations=False}, Convert`TeX`ExpressionToTeX[expr,o] ] Protect[Convert`TeX`ExpressionToTeX]; 

Then:

Root[#^3 + # + 1&, 2] //TeXForm 

$\text{Root}\left[\text{$\#$1}^3+\text{$\#$1}+1\&,2\right]$

If desired, a more targeted version that only affects Root object is also possible.

$\endgroup$
3
$\begingroup$

Here's a better fix, which is essentially the one I made to our nightly development version:

Convert`TeX`ExpressionToTeX; System`Convert`TeXFormDump`StripIdentityBoxes[System`Convert`CommonDump`boxes_]:= System`Convert`CommonDump`boxes //. { RowBox[{System`Convert`CommonDump`x_}]:>System`Convert`CommonDump`x, InterpretationBox[TemplateBox[_,"NumericalApproximation",___],System`Convert`CommonDump`x_,___] :> Block[{BoxForm`UseApproximations=False},MakeBoxes[System`Convert`CommonDump`x,TraditionalForm]], (AdjustmentBox|InterpretationBox|TagBox|DynamicBox|TooltipBox)[System`Convert`CommonDump`x_,___]:>System`Convert`CommonDump`x } 

This version will work not just with TeXForm but also with $\TeX$-Export and the various other ways $\TeX$ can be generated.

$\endgroup$
1
  • 1
    $\begingroup$ TeXForm is really overdue for a big update. I hope you are considering it for 12.1. $\endgroup$ Commented Apr 28, 2019 at 9:03

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.