[Tex/LaTex] stacking three tables on top of each other

floatstables

I generally have problems working within the figure and table environments. For my thesis I am using xtable to output my R data into latex code. I have three matrices that I would like to stack like the following picture:

enter image description here

Here is my current attempt but the error is `Not in outer par mode. \begin

\begin{figure}
    \centering
    \begin{subfigure}[b]{0.3\textwidth}
        \centering
        \begin{table}
            \begin{tabular}{rrrrrrrrrrr}
                \hline
                & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 \\ 
                \hline
                A & 0.10 & -1.64 & 1.17 & 0.50 & 0.81 & 0.63 & 1.00 & 0.31 & 1.00 & 0.07 \\ 
                C & 0.55 & 0.30 & -1.87 & -1.48 & -2.97 & -2.72 & -1.86 & -2.01 & -3.26 & -1.39 \\ 
                G & -1.72 & -2.75 & -1.35 & -1.70 & -2.65 & -2.54 & -2.93 & -1.59 & 0.11 & 0.88 \\ 
                T & -0.01 & 0.87 & -1.03 & 0.66 & 0.49 & 0.68 & 0.07 & 0.83 & -2.04 & -1.31 \\
                \hline
            \end{tabular}
        \end{table}
        \caption{$y=x$}
        \label{fig:y equals x}
    \end{subfigure}
    \centering
    \begin{subfigure}[b]{0.3\textwidth}
        \centering
        \begin{table}
            \begin{tabular}{rrrrrrrrrrr}
                \hline
                & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 \\ 
                \hline
                A & 518 &  91 & 1515 & 773 & 1054 & 880 & 1276 & 637 & 1272 & 502 \\ 
                C & 809 & 631 &  72 & 107 &  24 &  31 &  73 &  63 &  18 & 117 \\ 
                G &  84 &  30 & 121 &  86 &  33 &  37 &  25 &  96 & 524 & 1130 \\ 
                T & 464 & 1123 & 167 & 909 & 764 & 927 & 501 & 1079 &  61 & 126 \\ 
                \hline
            \end{tabular}
        \end{table}
        \caption{$y=x$}
        \label{fig:y equals x}
    \end{subfigure}

    \hfill
    \begin{subfigure}[b]{0.3\textwidth}
        \centering
        \begin{table}[ht]

            \begin{tabular}{rrrrrrrrrrr}
                \hline
                & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 \\ 
                \hline
                A & 0.28 & 0.05 & 0.81 & 0.41 & 0.56 & 0.47 & 0.68 & 0.34 & 0.68 & 0.27 \\ 
                C & 0.43 & 0.34 & 0.04 & 0.06 & 0.01 & 0.02 & 0.04 & 0.03 & 0.01 & 0.06 \\ 
                G & 0.04 & 0.02 & 0.06 & 0.05 & 0.02 & 0.02 & 0.01 & 0.05 & 0.28 & 0.60 \\ 
                T & 0.25 & 0.60 & 0.09 & 0.48 & 0.41 & 0.49 & 0.27 & 0.58 & 0.03 & 0.07 \\ 
                \hline
            \end{tabular}
        \end{table}
        \caption{$y=3sinx$}
        \label{fig:three sin x}
    \end{subfigure}
    \hfill

    \caption{Three simple graphs}
    \label{fig:three graphs}
\end{figure}

Best Answer

Here's a solution that uses three subtable environments (provided by the subcaption package) inside a table environment. (Since the material appears to be all tabular, I suggest using table and subtable environments instead of figure and subfigure environments.) I use \bigskip instructions to provide a bit more vertical separation between the subtable environments.

The code below also uses the line-drawing macros of the booktabs package for lines that have better vertical spacing than \hline, as well as the S column type (provided by the siunitx package) for the ten numeric data columns.

enter image description here

\documentclass{article}
\usepackage{subcaption,siunitx,booktabs}
\usepackage[margin=1in]{geometry} % choose margins to suit your needs
\begin{document}

\begin{table}

\begin{subtable}{1\textwidth}
\sisetup{table-format=-1.2}   % 2 decimals, leave space for minus sign
\centering
   \begin{tabular}{@{} l*{10}{S} @{}}
      \toprule
      & {1} & {2} & {3} & {4} & {5} & {6} & {7} & {8} & {9} & {10} \\ 
      \midrule
      A & 0.10 & -1.64 & 1.17 & 0.50 & 0.81 & 0.63 & 1.00 & 0.31 & 1.00 & 0.07 \\ 
      C & 0.55 & 0.30 & -1.87 & -1.48 & -2.97 & -2.72 & -1.86 & -2.01 & -3.26 & -1.39 \\ 
      G & -1.72 & -2.75 & -1.35 & -1.70 & -2.65 & -2.54 & -2.93 & -1.59 & 0.11 & 0.88 \\ 
      T & -0.01 & 0.87 & -1.03 & 0.66 & 0.49 & 0.68 & 0.07 & 0.83 & -2.04 & -1.31 \\
      \bottomrule
   \end{tabular}
   \caption{First subtable}\label{tab:sub_first}
\end{subtable}

\bigskip
\begin{subtable}{1\textwidth}
\sisetup{table-format=4.0} % integer values only, up to 4 digits
\centering
   \begin{tabular}{@{} l*{10}{S} @{}}
      \toprule
      & {1} & {2} & {3} & {4} & {5} & {6} & {7} & {8} & {9} & {10} \\ 
      \midrule
      A & 518 &  91 & 1515 & 773 & 1054 & 880 & 1276 & 637 & 1272 & 502 \\ 
      C & 809 & 631 &  72 & 107 &  24 &  31 &  73 &  63 &  18 & 117 \\ 
      G &  84 &  30 & 121 &  86 &  33 &  37 &  25 &  96 & 524 & 1130 \\ 
      T & 464 & 1123 & 167 & 909 & 764 & 927 & 501 & 1079 &  61 & 126 \\ 
      \bottomrule
   \end{tabular}
   \caption{Second subtable}\label{tab:sub_second}
\end{subtable}

\bigskip
\begin{subtable}{1\textwidth}
\sisetup{table-format=1.2} % up to two decimal digits, no minus signs
\centering
   \begin{tabular}{@{} l*{10}{S} @{}}
      \toprule
      & {1} & {2} & {3} & {4} & {5} & {6} & {7} & {8} & {9} & {10} \\ 
      \midrule
      A & 0.28 & 0.05 & 0.81 & 0.41 & 0.56 & 0.47 & 0.68 & 0.34 & 0.68 & 0.27 \\ 
      C & 0.43 & 0.34 & 0.04 & 0.06 & 0.01 & 0.02 & 0.04 & 0.03 & 0.01 & 0.06 \\ 
      G & 0.04 & 0.02 & 0.06 & 0.05 & 0.02 & 0.02 & 0.01 & 0.05 & 0.28 & 0.60 \\ 
      T & 0.25 & 0.60 & 0.09 & 0.48 & 0.41 & 0.49 & 0.27 & 0.58 & 0.03 & 0.07 \\ 
      \bottomrule
   \end{tabular}
   \caption{Third subtable}\label{tab:sub_third}
\end{subtable}

\caption{Three simple tables} \label{tab:three_tables}
\end{table}
\end{document}