[texhax] right-flushing or centered for vectors and arrays?
Hefferon, James S.
jhefferon at smcvt.edu
Thu Dec 22 01:26:55 CET 2011
Hello. I have been looking into the mathtools package and it has helped me a lot. I am now looking at right-flushing the columns of arrays and vectors. Below is my code, and the output is at http://i.imgur.com/nM3Od.png but my question basically is: is right-flushing a good idea, or is sticking to centered columns the best thing?
It seems to me that the column vectors do look better right-flushed if they are all numbers. But they can be awful if there are letters. So I wrote a little code to allow myself to have optional arguments, to have it both ways. Then, you guessed it, I found myself mixing the two not just in a single document or on a single page, but in one equation. Do other folks think this looks strange?
I've been looking at this for so long that I'm not sure I can see it straight anymore. I'd appreciate any wisdom that anyone can pass on. Is it better just to stick with centered column entries?
Thanks,
Jim Hefferon
-------------------- pdflatex source ----------------------------------------
\documentclass{article}
\usepackage{mathtools}
% With mathtools we can have column entries right flushed
% There is an optional argument \begin{mat}[r]{3} .. \end{mat} for
% right-flushed columns. Perhaps the rule is that numbers are better
% right-flushed but if there are any letters it is better centered?
\newenvironment{mat}[1][c]{\begin{pmatrix*}[#1]}{\end{pmatrix*}}
\newenvironment{amat}[2][c]{%
\left(\begin{array}{@{}*{#2}{#1}|#1@{}}
}{%
\end{array}\right)
}
\newcommand\vdotswithin[1]{% Taken from mathtools.dtx because my TL is not 2011
{\mathmakebox[\widthof{\ensuremath{{}#1{}}}][c]{{\vdots}}}}
% Colvec takes an optional argument \colvec[r]{x_1 \\ 0}. Perhaps
% digits look better right aligned, but if there are any letters it
% needs to be centered?
\newcommand{\colvec}[2][c]{\begin{mat}[#1] #2 \end{mat}}
\newcommand{\rowvec}[1]{\begin{mat} #1 \end{mat}}
\begin{document}
This is a column vector and a matrix with all numbers.
They are right-flushed.
\begin{equation*}
\begin{mat}[r]
3 &-3 \\
1.2 &-4.51
\end{mat}
\quad
\colvec[r]{-1 \\ 2 \\ 1.5}
\end{equation*}
This is the same, centered.
\begin{equation*}
\begin{mat}
3 &-3 \\
1.2 &-4.51
\end{mat}
\quad
\colvec{-1 \\ 2 \\ 1.5}
\end{equation*}
They seem to me to be better right-flushed, particularly the vector.
But sometimes right-flushed is a disaster.
\begin{equation*}
\begin{mat}[r]
x_1+2x_2 &-3 \\
1.2 &-4.51
\end{mat}
\quad
\colvec[r]{x_1+y_1 \\ 0}
\end{equation*}
So is the rule that all-numbers gets right flushed?
What about a mixture; do I mix the two in a single equation like this?
\begin{equation*}
\colvec[r]{4 \\ 1 \\ 0}m
+\colvec[r]{-1 \\ -3 \\ 0}n
=\colvec{c+d \\ -c+d \\ 0}
\end{equation*}
\end{document}
More information about the texhax
mailing list