# Inline row vectors with smallmatrix

I typeset inline column vectors with the smallmatrix environment from the amsmath package:

$\left(\begin{smallmatrix}a\\b\end{smallmatrix}\right)$


Unfortunately, when I do the same with row vectors I am not satisfied with the result since the height of the surrounding braces is the same as that of a column vector with two elements. Any recommendations of how to properly typeset the brackets?

• Welcome to TeX.SX! I usually typeset column vectors as row vectors with the symbol of transpose attached. If you want to do with smallmatrix, I see no problem, as the numbers in a row vector will be normal size. How do you type a row vector? – egreg Sep 10 '14 at 15:32
• $\left(\begin{smallmatrix}a & b\end{smallmatrix}\right)$ – user1225999 Sep 10 '14 at 15:36
• I realise this isn't a direct answer to your question, but smallmatrix isn't really suitable when you only have one row. Just use (x,y) or maybe (x\;y) (or in principle (\begin{matrix}x&y\end{matrix}, but this seems to put in too much horizontal space for an inline equation). – Jim Oldfield Sep 10 '14 at 15:36
• If I do this it looks awkward when displayed next to a column vector typeset with smallmatrix in order to squeeze it into a line since the vector entries are of different size. – user1225999 Sep 10 '14 at 15:39
• @user1225999 It does a little, but not nearly as awkward as what you're proposing, especially if it's in text that's normal size. The best overall solution is egreg's: write things like (x,y)^\mathrm{t}(a,b) (and only use smallmatrix for 2 by 2 matrices). – Jim Oldfield Sep 10 '14 at 15:48

## 3 Answers

I'm not sure you really want it, but here it is:

\documentclass{article}
\usepackage{amsmath}

\newcommand{\icol}{% inline column vector
\left(\begin{smallmatrix}#1\end{smallmatrix}\right)%
}

\newcommand{\irow}{% inline row vector
\begin{smallmatrix}(#1)\end{smallmatrix}%
}

\begin{document}

Text $\icol{a\\b}$ text $\irow{a&b}$ text
\end{document} If you change the definition of \irow into

\newcommand{\irow}{% inline row vector
\begin{smallmatrix}(\,#1\,)\end{smallmatrix}%
}


then the result is Refinements of the spacing are possible, but personally I'd go with no space.

• With mathtools one has smallpmatrix. – Manuel Sep 10 '14 at 15:43
• This solution isn't quite as good as David's (or rather, looks even more bad) because the first and last entries are a bit too close to the brackets. – Jim Oldfield Sep 10 '14 at 15:46
• @Manuel \begin{psmallmatrix}...\end{psmallmatrix} gives a result indistinguishable from \left(\begin{smallmatrix}...\end{smallmatrix}\right). Since I'm hiding this one in a macro, I won't bother. – egreg Sep 10 '14 at 15:47
• @egreg Okey, I thought, since the \icol looks quite spaced, that mathtools might correct that. – Manuel Sep 10 '14 at 15:50
• @Manuel That's an artifact of (round) parentheses; indeed I always use (square) brackets for matrices and vectors. – egreg Sep 10 '14 at 15:52

egreg will probably complain to me, but I think you are looking for: \documentclass{article}

\usepackage{amsmath}

\begin{document}

aaa $\left(\begin{smallmatrix}a & b\end{smallmatrix}\right)$
$\left(\begin{smallmatrix}a \\ b\end{smallmatrix}\right)$
$\mathopen{\scriptstyle(}\begin{smallmatrix}a & b\end{smallmatrix}\mathclose{\scriptstyle)}$

\end{document}

• It's much easier than this. – egreg Sep 10 '14 at 15:43
• @egreg I knew you would want to verify my first statement:-) – David Carlisle Sep 10 '14 at 15:44
• @DavidCarlisle Actually I prefer this solution over egregs since it uses the spacing of the smallmatrix. However, this solution also has a weird vertical placement of the elements: Compare a&b vs. x&y. – user1225999 Sep 11 '14 at 8:05

Shorter: the mathtools package defines a whole bunch of (small) matrices, with different alignments (star version). You don't have totypeset the delimiters. The case of row matrices can be managed with a special environment, with the help of the nccmath package. Sample:

\documentclass[11pt,a4paper]{article}

\usepackage{mathtools}

\begin{document}

$\begin{psmallmatrix*}[r]a\\bcd \end{psmallmatrix*}$

$\begin{psmallmatrix*}[l]a\\bcd \end{psmallmatrix*}$

$\begin{psmallmatrix}a\\ bcd \end{psmallmatrix}$

$\begin{psmallmatrix}a & bdc \end{psmallmatrix}$

\end{document} • But that has the exact problem the question is asking to avoid: your image shows the brackets in the last case are the same size as in the two row matrices. – David Carlisle Sep 10 '14 at 15:57
• @David Carlisle: I hadn't noticed, as I focused on the simpler syntax. I've a work-around, I'll upload it in a moment. – Bernard Sep 10 '14 at 16:18