12
$\begingroup$

I am not sure how to explain it, but whenever I compute something in Mathematica, the output always spits back the result in a Mathematica language as opposed to easy-to-read equations.

It's troublesome if my answer contains multiplies of parentheses and if my matrix is large.

Is there a way to make Mathematica display answers in "$\LaTeX$" form? So for instance, if i compute

RowReduce[{{1, 0}, {0, 1}}] 

How do I make it spit out a square matrix instead of giving me back {{1, 0}, {0, 1}}?

$\endgroup$
3
  • $\begingroup$ Try: {{1,0},{0,1}}//MatrixForm $\endgroup$ Commented Sep 22, 2012 at 23:05
  • 2
    $\begingroup$ There is also TeXForm. TeXForm[{{1, 0}, {0, 1}}] gives: $\left( \begin{array}{cc} 1 & 0 \\ 0 & 1 \\ \end{array} \right)$ $\endgroup$ Commented Sep 22, 2012 at 23:08
  • $\begingroup$ By the way, welcome to the site. Your question displays a bit more nicely now, too. ;) For future reference, here's the guide to formatting your posts. $\endgroup$ Commented Sep 22, 2012 at 23:20

1 Answer 1

19
$\begingroup$

Two possible answers.

  1. TexForm converts a Mathematica expression into something you can use to paste it in TeX:

    TeXForm[x/Sqrt[5]] ==> \frac{x}{\sqrt{5}} 

    A usually more convenient way of achieving this is right-clicking output, and selecting Copy as | LaTeX.

  2. If all you're looking for is a neater display form inside Mathematica, then have a look at MatrixForm and TraditionalForm.

    m = {{1, 2}, {3, 4}}; TraditionalForm[m] MatrixForm[m] 

    enter image description here

    Be careful only to use these commands to display already existing values. For example, when you're writing something like

    m = TraditionalForm[{{1, 2}, {3, 4}}]; Eigenvalues[m] 

    then m is not assigned the matrix, but its TraditionalForm representation, which does not behave like a matrix anymore. The output of the above is simply a silly line:

    enter image description here

$\endgroup$
5
  • $\begingroup$ Thanks, but I am not solely interested in just displaying matrices, but also simplifying integrals, expressions, etc... $\endgroup$ Commented Sep 23, 2012 at 0:37
  • 6
    $\begingroup$ @jak Then use a more illustrative example... You can't make matrices the focus of your question and expect us to divine that you actually wanted to simplify integrals $\endgroup$ Commented Sep 23, 2012 at 0:59
  • 2
    $\begingroup$ Actually I just found the solution. Under "preference" and "evaluation" in Mathematica, we can switch the output cells to TraditionalForm $\endgroup$ Commented Sep 23, 2012 at 2:05
  • $\begingroup$ Good to see you posting again, David. $\endgroup$ Commented Sep 23, 2012 at 2:44
  • 1
    $\begingroup$ @Mr.Wizard My activity on SE highly depends on what I'm currently using. Blame Haskell for my inactivity :-) $\endgroup$ Commented Sep 23, 2012 at 19:43

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.