7

I have three tables and I need that the three tables stays side by side.

I tried with this approach but the tables are overlapping each other.

\begin{table}[!htb]\tiny
    \begin{minipage}{.20\linewidth}
    \caption{First Table}
     \label{tab:first_table}
      \centering
         \begin{tabular}{ccccc}
    \toprule
    {\bf Library} & {\bf Comedy} & {\bf Scary} & {\bf Others} \\
    \midrule
    Library1 & $23$ & $233$ & $3295$ \\
    Library2 & $843$ & $0$ & $0$ \\
    Library3 & $11$ & $1$ & $0$ \\
    Library4 & $1$ & $0$ & $0$ \\
    \midrule
    {\bf Total} & $878$ & $234$ & $3295$ \\
    \bottomrule
    \end{tabular}
    \end{minipage}%
    \begin{minipage}{.20\linewidth}
      \centering
        \caption{Second Table}
    \label{tab:second_table}
        \begin{tabular}{ccccc}
    \toprule
    {\bf Library} & {\bf Comedy} & {\bf Scary} & {\bf Others} \\
    \midrule
    Library1 & $954$ & $40$ & $0$ \\
    Library2 & $32$ & $0$ & $1$ \\
    Library3 & $11$ & $132$ & $110$ \\
    Library4 & $1$ & $30$ & $67$ \\
    \midrule
    {\bf Total} & $998$ & $202$ & $178$ \\
    \bottomrule
    \end{tabular}    
      \end{minipage}%
    \begin{minipage}{.20\linewidth}
        \centering
        \caption{Third Table}
    \label{tab:third_table}
            \begin{tabular}{ccccc}
    \toprule
    {\bf Library} & {\bf Comedy} & {\bf Scary} & {\bf Others} \\
    \midrule
    Library1 & $483$ & $27$ & $2$ \\
    Library2 & $848$ & $220$ & $3$ \\
    Library3 & $121$ & $12$ & $40$ \\
    Library4 & $13$ & $0$ & $0$ \\
    \midrule
    {\bf Total} & $1465$ & $250$ & $45$ \\
    \bottomrule
    \end{tabular}    
\end{minipage} 
\end{table}

enter image description here

  • 1
    Change 0.2\linewidth to something larger. – Aditya Jan 22 '14 at 22:23
  • 1
    Please make your code compile by adding a document class, \begin{document} etc. That makes it much easier for people to help you (and so much more likely they'll give you useful input). – cfr Jan 22 '14 at 22:23
  • I would suggest making the intercolumn spacing a little smaller. Perhaps \setlength{\tabcolsep}{.7\tabcolsep} – Werner Jan 22 '14 at 22:23
6

You're setting the tables in minipages that are less wide than the tables.

Since the tables are in \tiny format, it's better to reduce the \tabcolsep, which by default is 6pt. Maybe 1pt is too little, experiment.

Note that \bf is an obsolete command.

\documentclass{article}
\usepackage{booktabs}

\begin{document}
\begin{table}[!htb]
\tiny\setlength{\tabcolsep}{1pt}
\begin{minipage}{.33\linewidth}
\centering

\caption{First Table}
\label{tab:first_table}

\medskip

\begin{tabular}{ccccc}
    \toprule
    \textbf{Library} & \textbf{Comedy} & \textbf{Scary} & \textbf{Others} \\
    \midrule
    Library1 & $23$ & $233$ & $3295$ \\
    Library2 & $843$ & $0$ & $0$ \\
    Library3 & $11$ & $1$ & $0$ \\
    Library4 & $1$ & $0$ & $0$ \\
    \midrule
    \textbf{Total} & $878$ & $234$ & $3295$ \\
    \bottomrule
\end{tabular}
\end{minipage}\hfill
\begin{minipage}{.3\linewidth}
\centering

\caption{Second Table}
\label{tab:second_table}

\medskip

\begin{tabular}{ccccc}
    \toprule
    \textbf{Library} & \textbf{Comedy} & \textbf{Scary} & \textbf{Others} \\
    \midrule
    Library1 & $954$ & $40$ & $0$ \\
    Library2 & $32$ & $0$ & $1$ \\
    Library3 & $11$ & $132$ & $110$ \\
    Library4 & $1$ & $30$ & $67$ \\
    \midrule
    \textbf{Total} & $998$ & $202$ & $178$ \\
    \bottomrule
\end{tabular}    
\end{minipage}\hfill
\begin{minipage}{.3\linewidth}
\centering

\caption{Third Table}
\label{tab:third_table}

\medskip

\begin{tabular}{ccccc}
    \toprule
    \textbf{Library} & \textbf{Comedy} & \textbf{Scary} & \textbf{Others} \\
    \midrule
    Library1 & $483$ & $27$ & $2$ \\
    Library2 & $848$ & $220$ & $3$ \\
    Library3 & $121$ & $12$ & $40$ \\
    Library4 & $13$ & $0$ & $0$ \\
    \midrule
    \textbf{Total} & $1465$ & $250$ & $45$ \\
    \bottomrule
\end{tabular}    
\end{minipage} 
\end{table}

\end{document}

enter image description here

  • Thanks, I do not know why but it only appears to me the third caption in the first table. Why? – user44589 Jan 22 '14 at 22:37
  • @user44589 Probably a consequence of your document class, or one of the packages you load. – Dan Jan 22 '14 at 23:03
  • I prefer \dimexpr\linewidth/3\relax instead of .33\linewidth. – kiss my armpit Jan 23 '14 at 1:12
3

use a correct value for the minipage width and resize the tabulars:

\documentclass[10pt]{article}
\usepackage{graphicx}
\usepackage{booktabs}
\begin{document}

\begin{table}[!htb]
\begin{minipage}[t]{.33\linewidth}
\caption{First Table}  \label{tab:first_table}
 \resizebox{\linewidth}{!}{%
    \begin{tabular}{@{}ccccc@{}}
    \toprule
    {\bf Library} & {\bf Comedy} & {\bf Scary} & {\bf Others} \\
    \midrule
    Library1 & $23$ & $233$ & $3295$ \\
    Library2 & $843$ & $0$ & $0$ \\
    Library3 & $11$ & $1$ & $0$ \\
    Library4 & $1$ & $0$ & $0$ \\
    \midrule
    {\bf Total} & $878$ & $234$ & $3295$ \\
    \bottomrule
    \end{tabular}%
}%
\end{minipage}%
\hfill%
\begin{minipage}[t]{.33\linewidth}
  \caption{Second Table}\label{tab:second_table}
 \resizebox{\linewidth}{!}{%
 \begin{tabular}{@{}ccccc@{}}
    \toprule
    {\bf Library} & {\bf Comedy} & {\bf Scary} & {\bf Others} \\
    \midrule
    Library1 & $954$ & $40$ & $0$ \\
    Library2 & $32$ & $0$ & $1$ \\
    Library3 & $11$ & $132$ & $110$ \\
    Library4 & $1$ & $30$ & $67$ \\
    \midrule
    {\bf Total} & $998$ & $202$ & $178$ \\
    \bottomrule
    \end{tabular}%
  }%
\end{minipage}%
\hfill%
\begin{minipage}[t]{.33\linewidth}
 \caption{Third Table} \label{tab:third_table}
 \resizebox{\linewidth}{!}{%
  \begin{tabular}{@{}ccccc@{}}
    \toprule
    {\bf Library} & {\bf Comedy} & {\bf Scary} & {\bf Others} \\
    \midrule
    Library1 & $483$ & $27$ & $2$ \\
    Library2 & $848$ & $220$ & $3$ \\
    Library3 & $121$ & $12$ & $40$ \\
    Library4 & $13$ & $0$ & $0$ \\
    \midrule
    {\bf Total} & $1465$ & $250$ & $45$ \\
    \bottomrule
    \end{tabular}%
 }%
\end{minipage} 
\end{table}

\end{document}

enter image description here

3

If you prefer to keep the column spacing, you could set the tabulars sideways by using a landscape environment. This example also introduces a little horizontal spacing between the tabulars to help keep them separate:

\documentclass{article}
\usepackage{booktabs}
\usepackage{pdflscape}
\begin{document}
\begin{landscape}
    \begin{table}[!htb]\scriptsize
    \begin{minipage}{.3\linewidth}
    \caption{First Table}
     \label{tab:first_table}
      \centering
         \begin{tabular}{ccccc}
    \toprule
    {\bf Library} & {\bf Comedy} & {\bf Scary} & {\bf Others} \\
    \midrule
    Library1 & $23$ & $233$ & $3295$ \\
    Library2 & $843$ & $0$ & $0$ \\
    Library3 & $11$ & $1$ & $0$ \\
    Library4 & $1$ & $0$ & $0$ \\
    \midrule
    {\bf Total} & $878$ & $234$ & $3295$ \\
    \bottomrule
    \end{tabular}
    \end{minipage}\hspace*{1em}
    \begin{minipage}{.3\linewidth}
      \centering
        \caption{Second Table}
    \label{tab:second_table}
        \begin{tabular}{ccccc}
    \toprule
    {\bf Library} & {\bf Comedy} & {\bf Scary} & {\bf Others} \\
    \midrule
    Library1 & $954$ & $40$ & $0$ \\
    Library2 & $32$ & $0$ & $1$ \\
    Library3 & $11$ & $132$ & $110$ \\
    Library4 & $1$ & $30$ & $67$ \\
    \midrule
    {\bf Total} & $998$ & $202$ & $178$ \\
    \bottomrule
    \end{tabular}
      \end{minipage}\hspace*{1em}
    \begin{minipage}{.3\linewidth}
        \centering
        \caption{Third Table}
    \label{tab:third_table}
            \begin{tabular}{ccccc}
    \toprule
    {\bf Library} & {\bf Comedy} & {\bf Scary} & {\bf Others} \\
    \midrule
    Library1 & $483$ & $27$ & $2$ \\
    Library2 & $848$ & $220$ & $3$ \\
    Library3 & $121$ & $12$ & $40$ \\
    Library4 & $13$ & $0$ & $0$ \\
    \midrule
    {\bf Total} & $1465$ & $250$ & $45$ \\
    \bottomrule
    \end{tabular}
\end{minipage}
\end{table}
\end{landscape}

\end{document}

Tabulars set sideways using <code>pdflscape</code>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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