Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Bug introduced in 9.0 and persisting through 10.1.0 or later

Update: Since no one has been able to give a reason for this change in behavior or provide a solution I am tagging this as a bug. Please report it to Wolfram Support if this affects your use of Mathematica.

In Mathematica 7 Row and TeXForm work harmoniously:

{x^a, Sqrt@b, ArcSin[c]} // Row // TeXForm
x^a\sqrt{b}\sin ^{-1}(c)

As LaTeX:

$x^a\sqrt{b}\sin ^{-1}(c)$

Unfortunately this is broken in more recent versions. Mathematica 10 returns:

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

This error was reported in version 9 as well.

An attempt at a workaround is to substitute Grid for Row but the LaTeX code generated is different:

{{x^a, Sqrt@b, ArcSin[c]}} // Grid // TeXForm

enter image description here

And it formats differently:

$\begin{array}{ccc} x^a & \sqrt{b} & \sin ^{-1}(c)

The documentation for TeXForm indicates that it is extensible with rules for Format but I could not fine a rule that worked. While I can manually convert a single Row as follows:

StringJoin[ToString /@ TeXForm /@ {x^a, Sqrt@b, ArcSin[c]}]
x^a\sqrt{b}\sin ^{-1}(c)

(Though note that one must copy as Plain Text.)

However attempting to make this a Format rule results in double-conversion and I get this:

enter image description here

Is this indeed a bug as I believe?

What is the best work-around for the problem, preferably automatic?

share|improve this question
does this help (TeXForm /@ {x^a, Sqrt@b, ArcSin[c]}) // Row – Algohi Jul 20 '14 at 7:58
@Algohi Thanks, but not really. This is similar to my own attempt near the bottom and it still doesn't allow for automatic conversion where Row is part of a larger expression. – Mr.Wizard Jul 20 '14 at 8:20
So have you reported it again Mr.W? – Jacob Akkerboom Jul 20 '14 at 9:33
@Jacob No I have not. I was waiting to see what others had to say about this. – Mr.Wizard Jul 20 '14 at 9:42
@Mr. Wizard I usually use RowBox and DisplayForm to get LaTex code from MM. I don't know if it works in MM10, since I don't have one. TeXForm /@ {x^a, Sqrt@b, ArcSin[c]} // RowBox // DisplayForm – Putterboy Jul 21 '14 at 19:07
up vote 8 down vote accepted

The following works in Version and Version

BoxForm`$UseTemplateSlotSequenceForRow = False; 
{x^a, Sqrt@b,  ArcSin[c]} // Row // TeXForm
(* x^a\sqrt{b}\sin^{-1}(c) *)
share|improve this answer
What on Earth is that?! +1 :-) – Mr.Wizard Sep 20 '14 at 16:45
@Mr.Wizard, it is something that show up when I used my whatOnEarthIs function: whatOnEarthIs = ToExpression["??*`*" ~~ ToString@# ~~ "*"] &; whatOnEarthIs@TemplateSlotSequence:) – kglr Sep 20 '14 at 17:49
This seems to restore the old behavior therefore I am Accepting it. Nevertheless I believe a bug remains in the current implementation as presumably TemplateSlotSequence is supposed to work and does not. – Mr.Wizard Sep 21 '14 at 11:08
TeXForm /@ {x^a, Sqrt@b, ArcSin[c]} // RowBox // DisplayForm

$x^a\sqrt{b}\sin ^{-1}(c)$

share|improve this answer
This works for a single row, as does my own StringJoin method, but I still don't know how to use this for a larger expression that contains a Row. If I use this method (or mine) to convert (only) the Row subexpressions, then apply TeXForm to the entire expression, the output is wrong. I could try to do everything in pieces then assemble them but there are too many possibilities to make that robust. – Mr.Wizard Jul 24 '14 at 10:03

What do you think about the following substitutions?

expr = Row@{x^a, Sqrt@b, ArcSin[c]};

expr /. Row@{x__} :> HoldForm@Times@x // TeXForm

$ x^a \sqrt{b} \sin ^{-1}(c) $

expr2 = Row[{x^a, Sqrt@b, ArcSin[c]}, d];

expr2 /. Row[x_, y_] :> HoldForm@*Times @@ Riffle[x, y] // TeXForm

$ x^a d \sqrt{b} d \sin ^{-1}(c) $

share|improve this answer
I haven't voted for this yet because I am unsure of Times being consistently formatted as a row. Could you comment on that? – Mr.Wizard Sep 20 '14 at 19:27
@Mr.Wizard As I understand now, not always :( For example, it add parenthesis for Row@{x+y,z}. Nothing can compete with incredible @kguler's solution. – ybeltukov Sep 20 '14 at 19:51

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.