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 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

share|improve this question
    
Change 0.2\linewidth to something larger. –  Aditya Jan 22 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 at 22:23
    
I would suggest making the intercolumn spacing a little smaller. Perhaps \setlength{\tabcolsep}{.7\tabcolsep} –  Werner Jan 22 at 22:23

3 Answers 3

up vote 5 down vote accepted

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

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

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

share|improve this answer

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>

share|improve this answer

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.