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

I would like to pretty print two column vectors of different lengths so that they are aligned at the top rather than centered, which seems to be the default. For example,

v1 = {a, b, c, d, 0, 0, 0}; v2 = {a, b, c, d};
Row[{MatrixForm[v1], MatrixForm[v2]}, Alignment -> {Center, Top}]

results in the pretty printing of the vectors but they are actually centered in the row rather than aligned with the horizontal position at the top.

Using a GraphicsRow instead of Row does work but changes the fonts from the rest of the nb so is only a second best solution.

Is there some other approach to this that I could try?

share|improve this question
up vote 1 down vote accepted
v1 = {a, b, c, d, 0, 0, 0}; v2 = {a, b, c, d};
Grid[{{MatrixForm[v1], MatrixForm[v2]}}, Alignment -> Top]

enter image description here

share|improve this answer
Many thanks, apologies that this was so easy. – pjc42 Jun 26 '13 at 0:44
Alignment is also an option for Row so I don't really understand why this works for Grid and not Row? – pjc42 Jun 26 '13 at 0:52
@pjc42 It is alignment within the total ImageSize of Raw, not for each element. – Vitaliy Kaurov Jun 26 '13 at 1:11
Got it, many thanks. – pjc42 Jun 26 '13 at 20:52

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.