It shows me like {{0}, {1}, {0}, {-1}} . Is it possible to make it look like a vector, always?

  • 1
    $\begingroup$ MatrixForm is what you are looking for. $\endgroup$
    – Kattern
    Commented May 18, 2015 at 2:36
  • 1
    $\begingroup$ I know about matrixform, but I dont want to type it everytime. $\endgroup$ Commented May 18, 2015 at 2:52
  • $\begingroup$ Two different users provided a $PrePrint solution in this Q&A: (3098). Perhaps this question should be close as a duplicate of that more elaborate one? $\endgroup$
    – Mr.Wizard
    Commented May 18, 2015 at 6:07
  • $\begingroup$ @Mr.Wizard I also thought to flag it for this, but this one actually is a really different question. $\endgroup$
    – Ruslan
    Commented May 18, 2015 at 12:45

2 Answers 2


Add this to your notebook or init file

    $PrePrint = If[MatrixQ[#], MatrixForm[#], #] &;

Then all matrices will automatically display as MatrixForm

Mathematica graphics


Mathematica graphics

If you want to format lists as column vectors also, try

$PrePrint = 
  Which[MatrixQ[#], MatrixForm[#], VectorQ[#], ColumnForm[#], 
    True, #] &;

Now also

Mathematica graphics


As @kattern pointed out, MatrixForm will pretty print your lists to look like matrices.

{{0}, {1}, {0}, {-1}} // MatrixForm

Mathematica graphics

A word of caution, however: MatrixForm can get in the way of your calculations if you are not careful. See this question and the related answers: Why does MatrixForm affect calculations?.

For instance, you could get bitten by something like this:

matWRONG = {{0}, {1}, {0}, {-1}} // MatrixForm
(matCORRECT = {{0}, {1}, {0}, {-1}}) // MatrixForm

Mathematica graphics

Both expressions print out a nice formatted version of your vector, but there is a subtle difference.

  • In the first case, you assigned the graphical output of MatrixForm, i.e. the pretty-printed form, to the variable matWRONG. That's probably not what you meant to do.
  • The second version assigns the vector to the matCORRECT variable, then pretty-prints the value of that variable. The variable itself contains the vector, and can be further operated upon.

For instance, you can transpose the matCORRECT vector, but if you try to do the same on the matWRONG one, Transpose will not recognize its input as a vector and return unevaluated, and you will probably be confused.


Mathematica graphics

  • $\begingroup$ would the macro he wrote cause any problems like this? $\endgroup$ Commented May 18, 2015 at 3:10
  • $\begingroup$ @grdgfgr As far as I know, it won't. In my understanding, in that case the pretty-printing will happen "last", i.e. after the assignments etc have already been taken care of. $\endgroup$
    – MarcoB
    Commented May 18, 2015 at 3:28

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.