21

Does anyone have a good idea for an alternative matrix definition with a font size between the standard size used for say pmatrix and the \scriptstyle size used by smallmatrix?

I have several vectors in manuscript that I'm editing, and I think

\begin{pmatrix}
1 \\ 2 
\end{pmatrix}

take up too much space and (requite mathtools)

\begin{psmallmatrix}
1 \\ 2
\end{psmallmatrix}

is too small.

The contents of these medium matrices may contain numbers and most likely also x_2 types of constructions.

Any ideas?

EDIT: My bad, I was of course referring to vertical vectors. And they will only be used in displayed mode.

2 Answers 2

9

You could combine Werner's \colvec with a small reduction of the interline space:

\documentclass{article}
\usepackage{graphicx,amsmath}
\newcommand{\colvec}[2][.8]{%
  \scalebox{#1}{%
    \renewcommand{\arraystretch}{.8}%
    $\begin{bmatrix}#2\end{bmatrix}$%
  }
}

\begin{document}
\[
\mathbf{a}+\colvec{x\\y\\z}+\begin{bmatrix}x\\y\\z\end{bmatrix}+\colvec[.7]{x\\y\\z}
\]
\end{document}

enter image description here

3
  • interesting, though this does scale the fences which may end up looking unnatural, but you have given me some ideas. Thanks both Werner and egreg
    – daleif
    Commented Jun 8, 2012 at 16:14
  • BTW: I don't think your image match your code ;-)
    – daleif
    Commented Jun 8, 2012 at 16:16
  • @daleif It's easy to end up with badly delimited matrices, in this way.
    – egreg
    Commented Jun 8, 2012 at 16:25
3

amsmath defines \substack for a very tight vertical stacking of elements (typically used as indices under operators like \sum. It's definition in amsmath.sty is:

\newenvironment{subarray}[1]{%
  \vcenter\bgroup
  \Let@ \restore@math@cr \default@tag
  \baselineskip\fontdimen10 \scriptfont\tw@
  \advance\baselineskip\fontdimen12 \scriptfont\tw@
  \lineskip\thr@@\fontdimen8 \scriptfont\thr@@
  \lineskiplimit\lineskip
  \ialign\bgroup\ifx c#1\hfil\fi
    $\m@th\scriptstyle##$\hfil\crcr
}{%
  \crcr\egroup\egroup
}
\newcommand{\substack}[1]{\subarray{c}#1\endsubarray}

Also, with \scriptsize being roughly 70% of \normalsize (in a 10pt base font), scaling at 80% is somewhere in between and might be useful. This requires graphicx. \colvec[<scale>]{<vector>} captures this (with a default <scale> of .8 or 80%):

\newcommand{\colvec}[2][.8]{%
  \scalebox{#1}{$\begin{array}{@{}c@{}}#2\end{array}$}}%

Here's a small example showing some comparison, plus a modification to \substack:

enter image description here

\documentclass{article}
\usepackage{graphicx}% http://ctan.org/pkg/graphicx
\usepackage{amsmath}% http://ctan.org/pkg/amsmath
\setlength{\parindent}{0pt}% Just for this example
\begin{document}
\verb|pmatrix|:
\[
  \begin{pmatrix}1\\2\end{pmatrix} \quad
  \begin{pmatrix}x_11\\2\end{pmatrix}
\]

\verb|smallmatrix|:
\[
  \left(\begin{smallmatrix}1\\2\end{smallmatrix}\right) \quad
  \left(\begin{smallmatrix}x_1\\2\end{smallmatrix}\right)
\]

\verb|\substack|:
\[
  \left(\substack{1\\2}\right) \quad
  \left(\substack{x_1\\2}\right)
\]

\makeatletter
\renewenvironment{subarray}[1]{%
  \vcenter\bgroup
  \Let@ \restore@math@cr \default@tag
  \baselineskip\fontdimen10 \scriptfont\tw@
  \advance\baselineskip\fontdimen12 \scriptfont\tw@
  \lineskip7\fontdimen8 \scriptfont\thr@@
  \lineskiplimit\lineskip
  \ialign\bgroup\ifx c#1\hfil\fi
    $\m@th##$\hfil\crcr
}{%
  \crcr\egroup\egroup
}
\makeatother
Updated \verb|\substack|:
\[
  \left(\substack{1\\2}\right) \quad
  \left(\substack{x_1\\2}\right)
\]

\newcommand{\colvec}[2][.8]{%
  \scalebox{#1}{$\begin{array}{@{}c@{}}#2\end{array}$}}%

\verb|\colvec|:
\[
  \Big(\colvec{1\\2}\Big) \quad
  \Big(\colvec{x_1\\2}\Big) \quad
  \bigg(\colvec{a\\b\\c}\bigg) \quad
  \bigg(\colvec[.7]{x_1\\x_2\\x_3}\bigg)
\]

\end{document}

This hasn't been extensively tested, since I'm not sure in which contexts it might fail or not.

1
  • The font sizes are the same, and they become too large if one use say a 3-dimensional vector or larger
    – daleif
    Commented Jun 8, 2012 at 8:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .