Same height for list of comma-separated vectors
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'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.
I've been playing around with this in plain-tex and wondered how do you feel about this:
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}
\}$
\bye