5

I have 2 tabular side by side. How can I label them as (a) and (b) and can be referred from text using \ref.

\begin{tabular}{ccc}
\hline
a&b&c\\
\hline
\end{tabular}
\quad
\begin{tabular}{ccc}
\hline
d&e&f\\
\hline
\end{tabular}
1
  • 3
    You can use the subcaption package.
    – percusse
    Mar 19, 2016 at 4:31

1 Answer 1

4

You will want to use the subcaption package for this purpose.

This package provides the subtable environment for the goal you wanted to achieve. Please read section 3 of the package documentation for details.

Please note how the \subref command has been used to refer to the subtables. If you want to refer using both main number and subnumber (e.g. 1(a)), you will want to use the \ref command. Format for all of these can be controlled. Please see the package documentation for this feature. Another useful document is here.

Anyway, here is your code.

\documentclass{article}

\usepackage{subcaption}

\begin{document}

\begin{table}[!tbp]
  \centering
  \begin{subtable}[t]{0.4\textwidth}
    \begin{center}
      \begin{tabular}{ccc}
        \hline
        a&b&c\\
        \hline
      \end{tabular}
      \caption{Table at left.}
      \label{tab:left}
    \end{center}
  \end{subtable}
  \quad
  \begin{subtable}[t]{0.4\textwidth}
    \begin{center}
      \begin{tabular}{ccc}
        \hline
        d&e&f\\
        \hline
      \end{tabular}
      \caption{Table at right.}
      \label{tab:right}
    \end{center}
  \end{subtable}
  \caption{This contains two subtables.}
  \label{tab:main}
\end{table}

Please see the left~(\subref{tab:left}) and right~(\subref{tab:right})
tables.

\end{document}

And here is the output.

enter image description here

2
  • Is there any known incompatibility issue with subcaption?
    – hola
    Dec 18, 2018 at 0:07
  • There are a few reported issues, 1, 2, and 3. Unfortunately, I don't have any firsthand experiences with these.
    – Masroor
    Dec 18, 2018 at 8:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .