I have a matrix equation like


I'd like to include the dimensions under each, like so

\underset{p\times k}{A} \underset{k\times 1}{x} = \underset{p\times 1}{b} 

The problem is that this is ugly, at least in the Beamer template I'm using. Is there a better way to typeset this?

2 Answers 2


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:



\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


If you want to get fancy, you could use TikZ:

TikZ suggestion


% for some reason it is impossible to define keys with arguments inside a frame.
\pgfkeys{/tikz/l/.style={right=0pt of #1.base east, anchor=base west}}


    inner sep=0,
    a/.style={->,shorten >=2pt,thick}
    \node[style-A] (A) {$A$};
    \node[l=A, style-x] (x) {$x$};
    \node[l=x] (eq) {${}={}$};
    \node[l=eq, style-b] (b) {$b$};

    \node[style-A] (A-desc) at (-0.5,-0.7) {$p \times k$};
    \node[style-x] (x-desc) at (0.5,-1.2) {$k \times 1$};
    \node[style-b] (b-desc) at (1.4,-0.7) {$p \times 1$};

    \draw[a,style-A] (A-desc) -- (A.south);
    \draw[a,style-x] (x-desc) -- (x.south);
    \draw[a,style-b] (b-desc) -- (b.south);
  • +1 for creativity! Giving it to @Gonzalo Medina as it's more comprehensive, but thanks
    – JMS
    Apr 11, 2011 at 17:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.