1
$\begingroup$

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?

$\endgroup$
1
$\begingroup$
v1 = {a, b, c, d, 0, 0, 0}; v2 = {a, b, c, d};
Grid[{{MatrixForm[v1], MatrixForm[v2]}}, Alignment -> Top]

enter image description here

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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