# How to add captions to individual tables inside tabular?

I have the following code which creates three tables side by side. How do I add a different caption to each of them separately?

\begin{table}
\footnotesize
\begin{tabular}{|l|l|}
\hline
Service  & Features \\
\hline
$S_{11}$ & $F_1$    \\
$S_{12}$ & $F_1$    \\
$S_{13}$ & $F_1$    \\
$S_{14}$ & $F_1$    \\
$S_{15}$ & $F_2$    \\
\hline
\end{tabular}
\hfill
\begin{tabular}{|l|l|}
\hline
Service  & Features \\
\hline
$S_{21}$ & $F_3$    \\
$S_{22}$ & $F_3$    \\
$S_{23}$ & $F_3$    \\
$S_{24}$ & $F_3$    \\
$S_{25}$ & $F_4$    \\
\hline
\end{tabular}
\hfill
\begin{tabular}{|l|l|}
\hline
Service  & Features \\
\hline
$S_{31}$ & $F_5$    \\
$S_{32}$ & $F_5$    \\
$S_{33}$ & $F_5$    \\
\hline
\end{tabular}

\caption{99 most frequent hashtags in the data set.}
\end{table}

• you can find your answer here: tex.stackexchange.com/questions/15282/… – Amin Heydari Alashti Apr 30 '19 at 6:19
• @epcpu The formatting gets messed up using this – kauray Apr 30 '19 at 6:23
• – leandriis Apr 30 '19 at 7:27
• Your question seems badly named: what you are asking for is caption for individual tabular inside table. – Jhor Apr 30 '19 at 8:19
• The answers prposed using mini pages do work. Nevertheless it seems over complicated. A more general and easy solution would be to load both the caption and subcaption packages (the latter loads the former) and use for each tabular the subtabke evironmemt (as provided by subcaption) ant the \captionof command in each subtable.Have a look at tex.stackexchange.com/q/383254/33514. – Jhor Apr 30 '19 at 8:26

it is not clear (to me), how you like to have captions to your tables, so below are two possible examples:

in the first is used tabularx for spreading tables in line, in the second are used subtable environments from subcaption package:

\documentclass{article}
\usepackage{tabularx}
\usepackage{subcaption}

\begin{document}
\begin{table}[htb]
\begin{tabularx}{\linewidth}{*{3}{>{\centering\arraybackslash}X}}
\begin{tabular}[b]{|l|l|}
\hline
Service  & Features \\
\hline
$S_{11}$ & $F_1$    \\
$S_{12}$ & $F_1$    \\
$S_{13}$ & $F_1$    \\
$S_{14}$ & $F_1$    \\
$S_{15}$ & $F_2$    \\
\hline
\end{tabular}
\caption{The first table}
&
\begin{tabular}[b]{|l|l|}
\hline
Service  & Features \\
\hline
$S_{21}$ & $F_3$    \\
$S_{22}$ & $F_3$    \\
$S_{23}$ & $F_3$    \\
$S_{24}$ & $F_3$    \\
$S_{25}$ & $F_4$    \\
\hline
\end{tabular}
\caption{The second table}
&
\begin{tabular}[b]{|l|l|}
\hline
Service  & Features \\
\hline
$S_{31}$ & $F_5$    \\
$S_{32}$ & $F_5$    \\
$S_{33}$ & $F_5$    \\
\hline
\end{tabular}
\caption{The third table}
\end{tabularx}
\end{table}
or
\begin{table}[htb]
\begin{subtable}[b]{0.3\linewidth}
\begin{tabular}{|l|l|}
\hline
Service  & Features \\
\hline
$S_{11}$ & $F_1$    \\
$S_{12}$ & $F_1$    \\
$S_{13}$ & $F_1$    \\
$S_{14}$ & $F_1$    \\
$S_{15}$ & $F_2$    \\
\hline
\end{tabular}
\caption{The first table}
\end{subtable}
\hfill
\begin{subtable}[b]{0.3\linewidth}
\begin{tabular}[b]{|l|l|}
\hline
Service  & Features \\
\hline
$S_{21}$ & $F_3$    \\
$S_{22}$ & $F_3$    \\
$S_{23}$ & $F_3$    \\
$S_{24}$ & $F_3$    \\
$S_{25}$ & $F_4$    \\
\hline
\end{tabular}
\caption{The second table}
\end{subtable}
\hfill
\begin{subtable}[b]{0.3\linewidth}
\begin{tabular}[b]{|l|l|}
\hline
Service  & Features \\
\hline
$S_{31}$ & $F_5$    \\
$S_{32}$ & $F_5$    \\
$S_{33}$ & $F_5$    \\
\hline
\end{tabular}
\caption{The third table}
\end{subtable}
\caption{99 most frequent hashtags in the data set.}
\end{table}
\end{document}


With minipages and the help of the capt-of package:

\documentclass{article}
\usepackage{geometry}
\usepackage{capt-of}
\begin{document}
\noindent
\begin{minipage}[t]{0.25\textwidth}
\footnotesize
\begin{tabular}[t]{|l|l|}
\hline
Service  & Features \\
\hline
$S_{11}$ & $F_1$    \\
$S_{12}$ & $F_1$    \\
$S_{13}$ & $F_1$    \\
$S_{14}$ & $F_1$    \\
$S_{15}$ & $F_2$    \\
\hline
\end{tabular}
\end{minipage}\hfill
\begin{minipage}[t]{0.25\textwidth}
\begin{tabular}[t]{|l|l|}
\hline
Service  & Features \\
\hline
$S_{21}$ & $F_3$    \\
$S_{22}$ & $F_3$    \\
$S_{23}$ & $F_3$    \\
$S_{24}$ & $F_3$    \\
$S_{25}$ & $F_4$    \\
\hline
\end{tabular}
\end{minipage}\hfill
\begin{minipage}[t]{0.25\textwidth}
\begin{tabular}[t]{|l|l|}
\hline
Service  & Features \\
\hline
$S_{31}$ & $F_5$    \\
$S_{32}$ & $F_5$    \\
$S_{33}$ & $F_5$    \\
\hline
\end{tabular}
\end{minipage}
\begin{minipage}[t]{0.25\textwidth}
\captionof{table}{Caption of first table}
\end{minipage}\hfill
\begin{minipage}[t]{0.25\textwidth}
\captionof{table}{Caption of second table}
\end{minipage}\hfill
\begin{minipage}[t]{0.25\textwidth}
\captionof{table}{Caption of third table}
\end{minipage}

\end{document}

• You can put more than one \caption inside a table environment. \captionof is not really needed. – John Kormylo Apr 30 '19 at 13:44