TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 2 down vote accepted

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

share|improve this answer

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);
share|improve this answer
+1 for creativity! Giving it to @Gonzalo Medina as it's more comprehensive, but thanks – JMS Apr 11 '11 at 17:09

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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