I successfully find

exp = CDF[TransformedDistribution[
 x1/(x1 + x2 + x3), 
  x1 \[Distributed] UniformDistribution[{0, 1}], 
  x2 \[Distributed] UniformDistribution[{0, 1}], 
  x3 \[Distributed] UniformDistribution[{0, 1}]
 ], t]

Then I copy the output as LaTeX and obtain

$$\begin{array}{cc} \{ & \begin{array}{cc} 1 & t>1 \\ -\frac{t}{t-1} & 0<t\leq \frac{1}{3} \\ \frac{5 t^2+2 t-1}{6 t^2} & \frac{1}{2}<t\leq 1 \\ \frac{21 t^3-27 t^2+9 t-1}{6 (t-1) t^2} & \frac{1}{3}<t\leq \frac{1}{2} \\ \end{array} \\ \end{array} $$

The result is not so good. On the other hand,

exp // TeXForm


$$\begin{cases} 1 & t>1 \\ -\frac{t}{t-1} & 0<t\leq \frac{1}{3} \\ \frac{5 t^2+2 t-1}{6 t^2} & \frac{1}{2}<t\leq 1 \\ \frac{21 t^3-27 t^2+9 t-1}{6 (t-1) t^2} & \frac{1}{3}<t\leq \frac{1}{2} \end{cases} $$

which is better. The questions arise: Why is the difference in the outputs observed? Can it be treated as a bug?

  • 2
    $\begingroup$ If you look at the Latex, the "Copy As" version starts with \begin{array} while the TeXForm version starts with \begin{cases}. So it looks like what's happening is that the "Copy As" version is building its latex off the form of the expression while the TeXForm is building its Latex from the meaning of the expression. $\endgroup$
    – bill s
    Commented Sep 13, 2018 at 18:10
  • $\begingroup$ @bill s: Thank you. You open an opened door. $\endgroup$
    – user64494
    Commented Sep 13, 2018 at 18:17
  • $\begingroup$ OP: I think @bills is actually on to something. If you look at the boxes that make up the formatted expression, you'll see that it is built as a GridBox—basically the same thing what you get when you use Copy As. The typeset version is just a "table" (a grid) without any meaning. The only reason it can even be converted back to a meaningful expression is the TagBox around it with the "Piecewise" marker. $\endgroup$
    – Szabolcs
    Commented Sep 13, 2018 at 18:58
  • $\begingroup$ Now, is it a bug? I don't know, but I would definitely report this to Wolfram. There might be a good reason why it behaves this way, but it's sure inconvenient. $\endgroup$
    – Szabolcs
    Commented Sep 13, 2018 at 18:59
  • 1
    $\begingroup$ Actually ... TeXForm@DisplayForm@First@ToBoxes[exp] still gives the cases version (the correct one), even though we manually removed the TagBox. So my hunch about what is happening may be wrong. Please do report it to Wolfram. $\endgroup$
    – Szabolcs
    Commented Sep 13, 2018 at 19:01

1 Answer 1


I think this is worth reporting to support. The issue is that the TeX conversion code has a special rule when a GridBox appears at the top level of the corresponding boxes that produces the output you want. Now, the TeXForm code path strips out "identity" boxes, and ends up with a GridBox at the top level that gets converted as desired. The Copy As Latex code path does not end up with a GridBox at the top level, and so the output gets converted differently.

You can modify an internal function to get the behavior you want:

System`Convert`TeXFormDump`StripIdentityBoxes[BoxData @ FormBox[e_, _]] := 
  • $\begingroup$ Thank you. You are a Mathematica expert. $\endgroup$
    – user64494
    Commented Sep 13, 2018 at 19:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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