Take the 2-minute tour ×
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.

I have a figure where I am writing som matrices I want something like

enter image description here

but I am getting this, How to change it?

enter image description here

I have

\begin {figure}[h]
\centering 
\small
 \textbf{X}
\[\left( \begin{array}{cccc}
x_{11} & x_{12} &\cdots & x_{1d} \\
x_{21} & x_{22} &\cdots & x_{2d} \\
\vdots & \vdots &\ddots & \vdots  \\
x_{n1} & x_{n2} &\cdots & x_{nd} \end{array} \right)\]
\[ \boldsymbol{n \times d} \]
\textbf{Data}
\Huge 
\[\downarrow \]
\small
\textbf{\[\rho\]}
\[\left( \begin{array}{cccc}
\rho_{11} & \rho_{12} &\cdots & \rho_{1d} \\
\rho_{21} & \rho_{22} &\cdots & \rho_{2d} \\
\vdots    & \vdots    &\ddots & \vdots    \\
\rho_{d1} & \rho_{d2} &\cdots & \rho_{dd} \end{array} \right)\]
\[ \boldsymbol{d \times d} \]
\textbf{Correlation Matrix}
\Huge 
\[\downarrow \]
\small
\textbf{U}
\[\left( \begin{array}{ccc}
u_{11} & \cdots & u_{1d} \\
\vdots & \ddots & \vdots    \\
u_{d1} & \cdots & u_{dd} \end{array} \right)\]
\[ \boldsymbol{d \times d} \]
\textbf{EigenVectors}
\textbf{\[\Sigma\]}
\[\left( \begin{array}{ccc}
\sigma_{11} & 0         & \cdots \\
0                & \ddots & \vdots    \\
\vdots        & \cdots & \sigma_{dd} \end{array} \right)\]
\[ \boldsymbol{d \times d} \]
\textbf{Singular Values}
\caption{ Steps in matrix notation of SVD}
\label{fig:stpeE}
\end{figure}
share|improve this question
1  
I will update my answer below later to satisfy what you want with a more intuitive way of typsetting such complex diagrams. Cheers... –  azetina Dec 8 '12 at 17:18
add comment

2 Answers 2

up vote 2 down vote accepted

Maybe this can help:

enter image description here

\documentclass[letterpaper]{article}
\usepackage{amsmath}
\usepackage{graphicx}
\begin{document}
\begin {figure}[h]
 \[
 \begin{array}{ccc}
 &
 \textbf{X}
 &\\
 &
 \left( \begin{array}{cccc}
x_{11} & x_{12} &\cdots & x_{1d} \\
x_{21} & x_{22} &\cdots & x_{2d} \\
\vdots & \vdots &\ddots & \vdots  \\
x_{n1} & x_{n2} &\cdots & x_{nd} \end{array} \right)
&\\
&
\boldsymbol{n \times d}
&\\[2ex]
&
\textbf{Data}
&\\
&
\downarrow
&\\
&
\resizebox{12pt}{!}{$\rho$}
&\\
&
\left( \begin{array}{cccc}
\rho_{11} & \rho_{12} &\cdots & \rho_{1d} \\
\rho_{21} & \rho_{22} &\cdots & \rho_{2d} \\
\vdots    & \vdots    &\ddots & \vdots    \\
\rho_{d1} & \rho_{d2} &\cdots & \rho_{dd} \end{array} \right)
&\\
&
\boldsymbol{d \times d}
&\\[2ex]
&
\textbf{Correlation Matrix}
&\\
&
\downarrow
&\\
\textbf{U} & \textbf{S} & \mathbf{V^T}\\
\left( \begin{array}{ccc}
u_{11} & \cdots & u_{1d} \\
\vdots & \ddots & \vdots    \\
u_{d1} & \cdots & u_{dd} \end{array} \right)
&
\left( \begin{array}{ccc}
s_{11} & \cdots & s_{1d} \\
\vdots & \ddots & \vdots    \\
s_{d1} & \cdots & s_{dd} \end{array} \right)
&
\left( \begin{array}{ccc}
v_{11} & \cdots & v_{1d} \\
\vdots & \ddots & \vdots    \\
v_{d1} & \cdots & v_{dd} \end{array} \right)
\\
\boldsymbol{d \times d}& \boldsymbol{d \times d}&\boldsymbol{d \times d}\\
\text{Eigen Values} & \text{Singular Values} & \text{Eigen Vectors}
 \end{array}
 \]
\caption{ Steps in matrix notation of SVD}
\label{fig:stpeE}
\end{figure}
\end{document}

The idea is to use an array to create the diagram itself. You can play around with the vertical spaces by adding empty lines or \\[<length>].

share|improve this answer
    
Cool answer, let me modify the last part \boldsymbol{d \times d}& \boldsymbol{d \times d} & \boldsymbol{d \times d} \end{array} \] instead of \boldsymbol{d \times d}& \boldsymbol{d \times d}7\boldsymbol{d \times d} \end{array} \] –  cMinor Dec 8 '12 at 17:37
    
Excuse me, If I want to use \mathbf how can I accomplish it? –  cMinor Dec 8 '12 at 17:42
    
@cMinor What do you mean? You mean \mathbf{<content>} instead of \boldsymbol? There is also the alternative; that is, using the bm package and writing \bm{<content>}. –  azetina Dec 8 '12 at 23:15
add comment

Here's an alternative answer:

To get the large arrow, I defined a new command. Also, I create your matrices using the pmatrix environment. It's worth looking this environment up. By defining your own environment for matrices:

\newenvironment{mymatrix}{\begin{pmatrix}}{\end{pmatrix}}

You can very easily change the parentheses to braces or none or some other style.

To get the three matrices at the bottom, I nest within another array envrionment. This will help with the labeling above and below each of the matrices.

\documentclass{article}
\usepackage{amsmath}
\newcommand{\Hdownarrow}{\mbox{\Huge$\downarrow$}}
\newenvironment{mymatrix}{\begin{pmatrix}}{\end{pmatrix}}
\pagestyle{empty}
\begin{document}

\begin {figure}[h]
\centering 
\small
\[
\begin{array}{@{}c@{}}
    \text{\textbf{X}}        \\
    \begin{mymatrix}
        x_{11} & x_{12} &\cdots & x_{1d} \\
        x_{21} & x_{22} &\cdots & x_{2d} \\
        \vdots & \vdots &\ddots & \vdots  \\
        x_{n1} & x_{n2} &\cdots & x_{nd} 
    \end{mymatrix} 
    \\[2ex]
    \boldsymbol{n \times d}  \\[4ex]
    \text{\textbf{Data}}     \\
    \Hdownarrow              \\
    \rho                     \\
    \begin{mymatrix}
        \rho_{11} & \rho_{12} &\cdots & \rho_{1d} \\
        \rho_{21} & \rho_{22} &\cdots & \rho_{2d} \\
        \vdots    & \vdots    &\ddots & \vdots    \\
        \rho_{d1} & \rho_{d2} &\cdots & \rho_{dd} 
    \end{mymatrix}
    \\
    \boldsymbol{d \times d}            \\
    \text{\textbf{Correlation Matrix}} \\[2ex]
    \Hdownarrow                        \\[3ex]
    \begin{array}{ccc}
        \text{\textbf{U}} & \text{\textbf{S}} & \text{\textbf{U}}\\
        \begin{mymatrix}
            u_{11} & \cdots & u_{1d}    \\
            \vdots & \ddots & \vdots    \\
            u_{d1} & \cdots & u_{dd} 
        \end{mymatrix} 
        &
        \begin{mymatrix}
            \sigma_{11} & 0      & \cdots    \\
            0           & \ddots & \vdots    \\
            \vdots      & \cdots & \sigma_{dd} 
        \end{mymatrix} 
        &
        \begin{mymatrix}
            \sigma_{11} & 0      & \cdots    \\
            0           & \ddots & \vdots    \\
            \vdots      & \cdots & \sigma_{dd} 
        \end{mymatrix} 
        \\
        d \times d & d\times d & d\times d   \\[2ex]
        \text{\textbf{EigenVectors}} & \text{\textbf{Singular Values}} & \text{?}
    \end{array}
\end{array}
\]
\caption{ Steps in matrix notation of SVD}
\label{fig:stpeE}
\end{figure}
\end{document}

enter image description here

share|improve this answer
1  
Please, never use eqnarray. Here a simple $\begin{array}{@{}c@{}} would do (and dispense with many &'s). Why \providecommand and \renewcommand? Wouldn't \newcommand suffice? –  egreg Dec 8 '12 at 17:35
    
Sorry. I didn't realize eqnarray was depricated. \newcommand is sufficient. The providecommand got in there because of a feature on my editor which I forgot to turn off. :( –  A.Ellett Dec 8 '12 at 17:41
add comment

Your Answer

 
discard

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.