并排摆放着三张桌子

并排摆放着三张桌子

我有三张桌子,我需要将这三张桌子并排摆放。

我尝试了这种方法,但表格互相重叠。

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

在此处输入图片描述

答案1

您正在设置的表格宽度小于表格宽度的迷你页面中。

由于表格是按\tiny格式排列的,因此最好减小\tabcolsep,默认情况下为 6pt。也许 1pt 太小了,请尝试一下。

请注意,这\bf是一个过时的命令。

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

在此处输入图片描述

答案2

使用正确的小页面宽度值并调整表格大小:

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

在此处输入图片描述

答案3

如果您希望保留列间距,可以使用横向环境将表格横向放置。此示例还在表格之间引入了一些水平间距,以帮助将它们分开:

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

使用 <code>pdflscape</code> 横向设置表格

相关内容