7

I have 8 vectors that I display as bmatrix in an align environment as follows:

But as you can see, the first vector is slightly thinner, making the rest unaligned aswell. How can I make the first vector as wide as the others? If someone knows how to make the heights the same aswell, that'd be even more awesome!

Here is a MWE:

\documentclass[preview, border = 2pt]{standalone} \usepackage{amsmath} \begin{document} \begin{align*} b_1 &= \begin{bmatrix} 0 \\ 0 \end{bmatrix}, \quad b_2 = \begin{bmatrix} \frac{1}{3} \\ 0 \end{bmatrix}, \quad b_3 = \begin{bmatrix} 0 \\ \frac{1}{3} \end{bmatrix}, \quad b_4 = \begin{bmatrix} \frac{1}{3} \\[.1cm] \frac{2}{3} \end{bmatrix} \\ b_5 &= \begin{bmatrix} \frac{2}{3} \\[.1cm] \frac{2}{3} \end{bmatrix}, \quad b_6 = \begin{bmatrix} \frac{2}{3} \\ 0 \end{bmatrix}, \quad b_7 = \begin{bmatrix} 0 \\ \frac{2}{3} \end{bmatrix}, \quad b_8 = \begin{bmatrix} \frac{2}{3} \\[.1cm] \frac{1}{3} \end{bmatrix} \end{align*} \end{document} 

EDIT: The following solution, as also provided by Ignasi, didn't fit my needs because I also had one-row cases that didn't need an align environment and it would look strange between equations.

\documentclass[preview, border = 2pt]{standalone} \usepackage{amsmath} \begin{document} \begin{align*} b_1 &= \begin{bmatrix} 0 \\ 0 \end{bmatrix}, & b_2 &= \begin{bmatrix} \frac{1}{3} \\ 0 \end{bmatrix}, & b_3 &= \begin{bmatrix} 0 \\ \frac{1}{3} \end{bmatrix}, & b_4 &= \begin{bmatrix} \frac{1}{3} \\ \frac{2}{3} \end{bmatrix} \\ b_5 &= \begin{bmatrix} \frac{2}{3} \\ \frac{2}{3} \end{bmatrix}, & b_6 &= \begin{bmatrix} \frac{2}{3} \\ 0 \end{bmatrix}, & b_7 &= \begin{bmatrix} 0 \\ \frac{2}{3} \end{bmatrix}, & b_8 &= \begin{bmatrix} \frac{2}{3} \\ \frac{1}{3} \end{bmatrix} \end{align*} \end{document} 
1
  • You could write 0/1 in the first vector ;) Commented Jul 10, 2015 at 10:09

2 Answers 2

8

You have two different spacing issues here. The first one is that 0 is not as wide as \frac{2}{3}. This can be corrected by setting the first number 0 in a \makebox with that very width.

The second issue is that you are having two different bracket sizes. The moment you correct your spacing by \\[.1cm], you get ugly alignment for the one-fraction-terms and the next bigger bracket size for the two-fractions-terms. Well, this would be not such a problem, if the spacing in front of those two bracket sizes would be the same. Unluckily it isn't. The bigger bracket occupies more space in front of it.

The easiest approach here would be to enlarge all vectors two the same size. Doing this, you will get the horizontal alignment you wish.

I used some Stefan Kottwitz magic to give every matrix an optional parameter for stretching it. I added the lua-visual-debug package in order to prove the perfect alignment. You can remove this and compile with PDFLaTeX instead.

% arara: lualatex \documentclass{article} \usepackage{amsmath} \usepackage{calc} \usepackage{lua-visual-debug} \makeatletter \renewcommand*\env@matrix[1][\arraystretch]{% \edef\arraystretch{#1}% \hskip -\arraycolsep \let\@ifnextchar\new@ifnextchar \array{*\c@MaxMatrixCols c}} \makeatother \begin{document} \begin{align*} b_1 &= \begin{bmatrix}[1.2] \makebox[\widthof{$\frac{1}{2}$}][c]{0} \\ 0 \end{bmatrix}, \quad b_2 = \begin{bmatrix}[1.2] \frac{1}{3} \\ 0 \end{bmatrix}, \quad b_3 = \begin{bmatrix}[1.2] 0 \\ \frac{1}{3} \end{bmatrix}, \quad b_4 = \begin{bmatrix}[1.2] \frac{1}{3}\\\frac{2}{3}\end{bmatrix}\\ %%%%%%%%%% b_5 &= \begin{bmatrix}[1.2] \frac{2}{3} \\ \frac{2}{3} \end{bmatrix}, \quad b_6 = \begin{bmatrix}[1.2] \frac{2}{3} \\ 0 \end{bmatrix}, \quad b_7 = \begin{bmatrix}[1.2] 0 \\ \frac{2}{3} \end{bmatrix}, \quad b_8 = \begin{bmatrix}[1.2] \frac{2}{3} \\ \frac{1}{3} \end{bmatrix} \end{align*} \end{document} 

enter image description here

2
  • This is awesome! It works like a charm and provides a solution to both problemd, thanks! Commented Jul 10, 2015 at 12:10
  • @DuctrTape You are very welcome. Glad it worked. The second issue can be omitted by taking the font Asana Math which has the same spacing for every bracket size. Latin Modern does increase this space with every next size. STIX does something strange (reported that to the maintainers.) Commented Jul 10, 2015 at 14:40
3

align can have as many alignment points as you want, not only one:

\documentclass[preview, border = 2pt]{standalone} \usepackage{amsmath} \begin{document} \begin{align*} b_1 &= \begin{bmatrix} 0 \\ 0 \end{bmatrix}, & b_2 &= \begin{bmatrix} \frac{1}{3} \\ 0 \end{bmatrix}, & b_3 &= \begin{bmatrix} 0 \\ \frac{1}{3} \end{bmatrix}, & b_4 &= \begin{bmatrix} \frac{1}{3} \\ \frac{2}{3} \end{bmatrix} \\ b_5 &= \begin{bmatrix} \frac{2}{3} \\ \frac{2}{3} \end{bmatrix}, & b_6 &= \begin{bmatrix} \frac{2}{3} \\ 0 \end{bmatrix}, & b_7 &= \begin{bmatrix} 0 \\ \frac{2}{3} \end{bmatrix}, & b_8 &= \begin{bmatrix} \frac{2}{3} \\ \frac{1}{3} \end{bmatrix} \end{align*} \end{document} 

enter image description here

4
  • I tried that solution as first, but in other places in the document I have the same equation but with only one row. That makes it look strange across equations. Commented Jul 10, 2015 at 10:44
  • @DuctrTape -- add this information to your question. it will make it more helpful to others reading it in the future. Commented Jul 10, 2015 at 12:37
  • @barbarabeeton Done, hope it's okay like this. Commented Jul 10, 2015 at 12:48
  • @DuctrTape -- just stating the fact that you have a one-line equation would have been adequate, but yes, what you've done is fine. thanks. Commented Jul 10, 2015 at 16:51

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.