[Tex/LaTex] Three tables side by side

positioningtables

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

Best Answer

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

Related Question