# Same height for list of comma-separated vectors

I am trying to typeset a list of vectors spanning a multidimensional space, using the notation span{v_1,v_2,...,v_n} (I haven't found out how to inline it as rendered latex) i.e.:

span \{
\begin{pmatrix} 1      \\ \vdots \\ \vdots \\ 1      \\ 1      \end{pmatrix},
\begin{pmatrix} 0      \\ 1      \\ \vdots \\ \vdots \\ 1      \end{pmatrix},
\begin{pmatrix} 0      \\ 0      \\      1 \\ \vdots \\ 1      \end{pmatrix}
\begin{matrix}  \cdots \\        \\ \ddots \\ \ddots \\ \cdots \end{matrix}
\begin{pmatrix} 0      \\ \vdots \\ \vdots \\      0 \\ 1      \end{pmatrix}
\}

but the fourth "vector", consisting of only various dots does not have the same size as the other vectors, since the dots take up more vertical space than 1 or 0 do.

I understand LaTeX doesn't know how to align them since they are all independent matrices but I'm not satisfied with the result. Is there any way to make them all have the same height?

-
TeX.SE has rendered latex disabled. you can read about it in the meta. it caused too many problems because it was triggered when not wanted. –  Yossi Farjoun Oct 31 '10 at 14:20

You may want to take a look at easybmat:

\documentclass{article}
\usepackage{easybmat}

%\usepackage{etex} % if you also want tikz, then you also need etex,
%\usepackage{tikz} % and they have to be loaded AFTER easybmat

\newenvironment{bvec}[1]{\begin{BMAT}(r)[0pt]{c}{#1}}{\end{BMAT}}
\newenvironment{pbvec}[1]{\left(\begin{bvec}{#1}}{\end{bvec}\right)}

\begin{document}
$span \{ \begin{pbvec}{ccccc} 1 \\ \vdots \\ \vdots \\ 1 \\ 1 \end{pbvec}, \begin{pbvec}{ccccc} 0 \\ 1 \\ \vdots \\ \vdots \\ 1 \end{pbvec}, \begin{pbvec}{ccccc} 0 \\ 0 \\ 1 \\ \vdots \\ 1 \end{pbvec} \begin{bvec}{ccccc} \cdots \\ {} \\ \ddots \\ \ddots \\ \cdots \end{bvec} \begin{pbvec}{ccccc} 0 \\ \vdots \\ \vdots \\ 0 \\ 1 \end{pbvec} \}$
\end{document}


which results in

There are a few annoying things with BMAT:

• You must declare the number of columns at the top (I have no idea why, but I guess this has to do with the fact that they can be align differently or something)
• You cannot have empty rows (see {} in the fourth line).
-
I'm assuming this was typed up without too much work, but for the sake of the OP, might use \left\{ and \right\} to have the braces encompass the vectors, and use \text{span} to have it typeset properly. At least that's the way my linear algebra professor does it. –  EricR Oct 31 '10 at 14:19
Instead of \text, you should \mathrm (so that it does not inherit formatting from the surrounding text). –  Caramdir Oct 31 '10 at 17:02
Hmmm. I don't like telling people what they should do. The OP asked about how to make the vectors the same size and that is what I wanted to focus my answer on. I actually think it looks better with the small braces, in this case, and about the word "span", well, the OP can decide what he wants to do. I'd rather no evangelize. Feel free to comment on the original question, or add an alternative answer if you like. –  Yossi Farjoun Oct 31 '10 at 20:50
How about \operatorname{span} or, since this is likely a common thing to want, \DeclareMathOperator{\span}{span} in the preamble and then use \span. –  TH. Oct 31 '10 at 21:17
It works like a charm, thanks a lot! As for the \{, I also think it looks better when it's small but that clearly is a matter of taste. –  jonny Nov 1 '10 at 8:36

I'd like to expand a bit on Yossi's answer. If you look at the image he provided, then you can see that the \vdots and the \ddots are rather low; they don't look vertically centered. The reason seems to be that the definition of \vdots in plain.tex and the BMAT don't work together well: The {ccccc} part in Yossi's answer means that all the 5 entries in the vector are vertically centered, and the plain TeX definition of \vdots is

\def\vdots{\vbox{\baselineskip4\p@ \lineskiplimit\z@
\kern6\p@\hbox{.}\hbox{.}\hbox{.}}}


Thus, \vdots is a vertical box containing 6pt white space and 3 evenly spaces dots, and one shouldn't be too surprised that the dots are sitting too low in the BMAT vector. I still don't quite understand why \vdots is defined like this, but is does work together well with plain TeX's \pmatrix. In the following image you can compare \pmatrix{1\cr \vdots\cr \vdots\cr 1\cr 1} from plain TeX, \begin{pmatrix} 1 \\ \vdots \\ \vdots \\ 1 \\ 1 \end{pmatrix} from amsmath, and the vector produced by Yossi's pbvec:

Unfortunately I can't explain all the differences. For me the plain TeX vector looks best, even if I'd like to have the parentheses a bit closer to the numbers, as in the other vectors. To get a similar result with BMAT, it does not help using "t" or "b" instead of "c", which would give "top" or "bottom" vertical alignment. The only idea I have is to define vertically centered \vdots, so here's the solution I would suggest:

\documentclass{article}
\usepackage{amsmath,easybmat}

\newcommand*{\bvector}[1]{\begin{BMAT}(r)[0pt]{c}{ccccc}#1\end{BMAT}}
\newcommand*{\pbvector}[1]{\left(\bvector{#1}\right)}
\makeatletter
\def\vcdots{\vbox{\baselineskip4\p@ \lineskiplimit\z@
\kern3\p@\hbox{.}\hbox{.}\hbox{.}\kern3\p@}}
\makeatother

\begin{document}
$\operatorname{span} \{ \pbvector{ 1 \\ \vcdots \\ \vcdots \\ 1 \\ 1 }, \pbvector{ 0 \\ 1 \\ \vcdots \\ \vcdots \\ 1 }, \pbvector{ 0 \\ 0 \\ 1 \\ \vcdots \\ 1 } \bvector{ \cdots \\ {} \\ \ddots \\ \ddots \\ \cdots } \pbvector{ 0 \\ \vcdots \\ \vcdots \\ 0 \\ 1 } \}$

\end{document}


Note that I haven't changed the \ddots, so they are a bit lower than the \vdots, but of course this could be fixed, too.

One last word that explains why BMAT yields the desired alignment: I think it sets the height of all the entries in the vector to the maximum height it finds in the vector. So here it works since for all the vectors this maximum height is the same. It goes terribly wrong if in the third vector you replace \vcdots with, say, 0.

-
span $\def\svdots{\lower1pt\hbox{$\smash\vdots$}} \def\sddots{\lower1pt\hbox{$\smash\ddots$}} \{ \pmatrix{1\cr \svdots\cr \svdots\cr 1\cr 1}, \pmatrix{0\cr 1\cr \svdots\cr \svdots\cr 1}, \pmatrix{0\cr 0\cr 1\cr \svdots\cr 1} \matrix {\cdots\cr \cr \sddots\cr \sddots\cr \cdots\cr} \pmatrix{0\cr \svdots\cr \svdots\cr 0\cr 1} \}$