In[116]:= Abs[a^n] // TeXForm                                                   

Out[116]//TeXForm= \left\left| a^n\right\right|

But the result isn't valid TeX. It won't work here:

$\left\left| a^n\right\right|$

or on texpaste.com, where the error is "Missing or unrecognized delimiter for \left".

Is this a known bug and is there a known workaround?

OK, it turns out the workaround is to just remove the spurious \left and \right, so that \left| a^n\right| works fine:

$\left| a^n\right|$

However, not sure if this workaround works in general, or just in this simple case.

In[49]:= $Version                                                               

Out[49]= 9.0 for Linux x86 (32-bit) (November 20, 2012)
  • $\begingroup$ This looks like a bug to me. You should edit your question to include the Mathematica version and the OS you're using. I can reproduce the bug in MM under Mac OS 10.10.5 $\endgroup$ – Michael Seifert Mar 3 '16 at 20:17
  • $\begingroup$ Please note that TeXForm produces AMS-LaTeX-compatible TeX output. This is documented in the "Details" section of the TeXForm documentation. In LaTeX, \left and \right are used for delimiters when they have to change the size dynamically depending on the content. $\endgroup$ – Arnoud Buzing Mar 3 '16 at 20:45
  • $\begingroup$ @ArnoudBuzing The issue here is \left\left, not just \left which should be fine. Can \left be followed by another \left in AMS-LaTeX? In other words, \left is being used as a delimiter for another \left which is probably wrong. You need \left(something) not \left\left $\endgroup$ – user1722 Mar 3 '16 at 20:47
  • $\begingroup$ It seemed to be fine when I tried your example here: codecogs.com/latex/eqneditor.php. But you're right that it looks wrong (and probably is wrong in general). $\endgroup$ – Arnoud Buzing Mar 3 '16 at 20:51
  • 2
    $\begingroup$ This is old hat. It has been reported in at least three posts: 54857, 76839 and 29356. The first one also contains a solution. $\endgroup$ – Sjoerd C. de Vries Mar 3 '16 at 21:20

(Please see comment section above)

Barry, please evaluate this code below and then try any TeXForm that uses Abs that you may have:

 TemplateBox[{System`Convert`CommonDump`n_}, "Abs", ___]
] := "\\left| " <> 
 System`Convert`TeXFormDump`MakeTeX[System`Convert`CommonDump`n] <> 
 " \\right|"
| improve this answer | |
  • $\begingroup$ Thanks! That worked and I've added it to my initfile. $\endgroup$ – user1722 Mar 3 '16 at 21:29