georgefrost123 wrote:Is is possible to centralise (or right-align) the elements in the matrix?
Yes, it is possible. The environment
smallmatrix, by default, centers the entries. In the following code I defined two mew environments similar to
smallmatrix:
lsmallmatrix (left alignment for the entries) and
rsmallmatrix (right alignment for the entries).
I used those (together with
smallmatrix) to define new commands for 3x1 matrices with different alignment. The example shows the new environments and commands in action:
Code: Select all
\documentclass{article}
\usepackage{amsmath}
\makeatletter
% smallmatrix with left alignment
\newenvironment{lsmallmatrix}{\null\,\vcenter\bgroup
\Let@\restore@math@cr\default@tag
\baselineskip6\ex@ \lineskip1.5\ex@ \lineskiplimit\lineskip
\ialign\bgroup$\m@th\scriptstyle##$\hfil&&\thickspace\hfil
$\m@th\scriptstyle##$\hfil\crcr
}{%
\crcr\egroup\egroup\,%
}
% smallmatrix with right alignment
\newenvironment{rsmallmatrix}{\null\,\vcenter\bgroup
\Let@\restore@math@cr\default@tag
\baselineskip6\ex@ \lineskip1.5\ex@ \lineskiplimit\lineskip
\ialign\bgroup\hfil$\m@th\scriptstyle##$&&\thickspace\hfil
$\m@th\scriptstyle##$\hfil\crcr
}{%
\crcr\egroup\egroup\,%
}
\makeatother
% 3x1 smallmatrix with left alignment
\newcommand{\ltvect}[3]{%
\ensuremath{\Bigl(\negthinspace\begin{lsmallmatrix}#1\\#2\\#3\end{lsmallmatrix}\Bigr)}}
% 3x1 smallmatrix with right alignment
\newcommand{\rtvect}[3]{%
\ensuremath{\Bigl(\negthinspace\begin{rsmallmatrix}#1\\#2\\#3\end{rsmallmatrix}\Bigr)}}
% 3x1 smallmatrix with centered entries
\newcommand{\ctvect}[3]{%
\ensuremath{\Bigl(\negthinspace\begin{smallmatrix}#1\\#2\\#3\end{smallmatrix}\Bigr)}}
\begin{document}
Example of a smallmatrix with left alignment
$\begin{lsmallmatrix}
5\\-1000\\3\\2
\end{lsmallmatrix}$
\vspace{1cm}
Example of a smallmatrix with right alignment
$\begin{rsmallmatrix}
5\\-1000\\3\\2
\end{rsmallmatrix}$
\vspace{1cm}
Example of a smallmatrix with centered entries
$\begin{smallmatrix}
5\\-1000\\3\\2
\end{smallmatrix}$
\vspace{1cm}
% left alignment
text text text text text text text text text text text text text text text text text text text
text $\ltvect{-100000}{2}{3}$ text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text
% right alignment
text text text text text text text text text text text text text text text text text text text
text $\rtvect{-100000}{2}{3}$ text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text
% centered
text text text text text text text text text text text text text text text text text text text
text $\ctvect{-100000}{2}{3}$ text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text
\end{document}
georgefrost123 wrote:...Also, I'm guessing that \ensuremath{...} appends $s accordingly to prevent errors? Finally (sorry for the many questions!), does the \negthinspace ensure the left bracket sits properly alongside the column?..
Don't worry; you can ask as many questions as you wish.
\ensuremath is a LaTeX2e command that ensures that its argument is typeset always in math mode by enclosing it, if necessary, with
$ signs.
\negthinspace,
\negmedspace and
\negthickspace are commands implemented by the
amsmath package to produce negative horizontal spacing; their default value is
3mu,
4mu plus 2mu minus 4mu, and
5mu plus 5mu, respectively. Those commands can be used both in text and math mode.
1,1,2,3,5,8,13,21,34,55,89,144,233,...