Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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

1 Answer 1

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
1  
@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

 
discard

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.