It's common to place the matrix dimensions as subscripts, so you could use
\[
A_{\scriptscriptstyle p\times k}x_{\scriptscriptstyle k\times 1}=b_{\scriptscriptstyle p\times 1}
\]
EDIT: an option would be to show the dimensions only on one slide and to hide them on other slide(s) using something like this:
\[
\onslide<1,2>{A}\only<1>{_{\scriptscriptstyle p\times k}}
\onslide<1,2>{x}\only<1>{_{\scriptscriptstyle k\times 1}} =
\onslide<1,2>{b}\only<1>{_{\scriptscriptstyle p\times 1}}
\]
EDIT2: a variant on Caramdir's solution, but focusing on the contents:
\documentclass{beamer}
\usepackage{tikz}
\usefonttheme[mathonly]{serif}
\begin{document}
\begin{frame}
\begin{center}
\begin{tikzpicture}[every node/.style={inner sep =1pt},dim/.style={red!50!black}]
\onslide<1->{\node (meq) at (0,0) {$Ax=b$};}
\onslide<2->{\node[dim] (A) at (-1,-0.8) {$\scriptscriptstyle p\times k$};
\draw[->,red!50!black] (A) -- (meq.200);}\pause
\onslide<3->{\node[dim] (x) at (-0.25,-0.8) {$\scriptscriptstyle k\times 1$};
\draw[->,red!50!black] (x) -- (meq.215);}\pause
\onslide<4->{\node[dim] (b) at (1,-0.8) {$\scriptscriptstyle p\times 1$};
\draw[->,red!50!black] (b) -- (meq.341);}\pause
\end{tikzpicture}
\end{center}
\end{frame}
\end{document}
In today's I have too much free time episode we will attack a question posted without a MWE. Absence of a MWE gives us the right to go as esoteric as possible hence here is one Tweak this, tweak that possibility.
\documentclass[tikz]{standalone}
\usetikzlibrary{matrix,trees}
\begin{document}
\begin{tikzpicture}[level distance=7mm,
level 1/.style={sibling distance=8mm},
level 2/.style={sibling distance=4mm},
]
\matrix (m) [mymatrix/.style={execute at empty cell=
\ifnum\pgfmatrixcurrentrow<5
\ifnum\pgfmatrixcurrentcolumn>4
\node\bgroup$0$\egroup;\fi
\else
\ifnum\pgfmatrixcurrentcolumn<5
\node\bgroup$0$\egroup;\fi
\fi
},mymatrix,
right delimiter={]},left delimiter={[}]{
&&&&&&&\\
&&&&&&&\\
&&&&&&&\\
&&&&&&&\\
&&&&&&&\\
&&&&&&&\\
&&&&&&&\\
&&&&&&&\\
};
\begin{scope}[edge from parent path=
{(\tikzparentnode.south) .. controls +(0,-0.2) and +(0,0.2)
.. (\tikzchildnode.north)}]
\node at ([yshift=1.5cm]m.67) {$A$}
child {node {$1$}
child {node {S}}
child {node {I}}}
child {node {$2$}
child {node {S}}
child {node {I}}
};
\node at ([yshift=1.5cm]m.113) {$B$}
child {node {$1$}
child {node {S}}
child {node {I}}}
child {node {$2$}
child {node {S}}
child {node {I}}
};
\end{scope}
\begin{scope}[edge from parent path=
{(\tikzparentnode.east) .. controls +(0.2,0) and +(-0.2,0)
.. (\tikzchildnode.west)},level distance=6mm,
level 1/.style={sibling distance=9.2mm},
level 2/.style={sibling distance=4.5mm}]
\node at ([xshift=-1.6cm]m.152) {$A$}[grow=right]
child {node {$1$}
child {node {S}}
child {node {I}}}
child {node {$2$}
child {node {S}}
child {node {I}}
};
\node at ([xshift=-1.6cm]m.-152) {$B$}[grow=right]
child {node {$1$}
child {node {S}}
child {node {I}}}
child {node {$2$}
child {node {S}}
child {node {I}}
};
\end{scope}
\end{tikzpicture}
\end{document}
Best Answer
Here I do it with stacks, setting the indices below the boxes. The primary macro is
\matbox{rows}{columns}{row index}{column index}{matrix name}
.A helper macro is
\raiserows
, which is like a\raisebox
, except that the "length" is specified in rows, not actual length. Note that in the MWE, becauseX
has 7 rows, whileP^T
only has 2 rows,P^T
must be lifted (7-2)/2 = 2.5 rows.I introduce the factor
\matscale
to scale your box sizes. By default, each row and column of the box size will occupy a square of size\baselineskip
on a side. The factor\matscale
(which defaults to 1) will scale that value.EDITED to set array indices in
\scriptstyle
Just to clarify, in case it wasn't clear. One can use actual (very large) matrix dimensions, as long as one scales suitably small. For example, the following works::