我有两个几乎完全相同的表,如下所示:
\begin{table}[!ht]
\fontsize{8}{8}\selectfont
\caption{caption$.}
\label{label}
\center{
\begin{tabular}{|c|c|c|c|}
\hline
$and$&$this$&$is$&$something$\\
\hline
1&1&1&1\\
\hline
1&1&1&1\\
\hline
1&1&1&1\\
\hline
1&1&1&1\\
\end{tabular}
}
\end{table}
\begin{table}[!ht]
\fontsize{8}{8}\selectfont
\caption{caption$.}
\label{label}
\center{
\begin{tabular}{|c|c|c|c|}
\hline
$and$&$this$&$is$&$something$\\
\hline
1&1&1&1\\
\hline
1&1&1&1\\
\hline
1&1&1&1\\
\hline
1&1&1&1\\
\end{tabular}
}
\end{table}
我知道这些表格本身并不是最佳做法,但是,假设我被它们困住了,将两个这样的表格并排放置的最佳做法是什么?
答案1
以下是该包的使用说明floatrow
:
\documentclass[a4paper, 11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{lipsum}
\usepackage{graphicx}
\usepackage{floatrow}
\DeclareFloatSeparators{mysep}{\hskip4em}
\begin{document}
Text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text.
\begin{table}[!ht]\centering
\fontsize{8}{8}\selectfont
\floatsetup{floatrowsep=mysep}
\begin{floatrow}
\ttabbox[\FBwidth]
{\begin{tabular}{|c|c|c|c|}
\hline
$and$&$this$&$is$&$something$\\
\hline
1&1&1&1\\
\hline
1&1&1&1\\
\hline
1&1&1&1\\
\hline
1&1&1&1\\
\hline
\end{tabular}}%
{\caption{caption A.}\label{labelA}}
%%
\ttabbox[\FBwidth]
{\begin{tabular}{|c|c|c|c|}
\hline
$and$&$this$&$is$&$something$\\
\hline
1&1&1&1\\
\hline
1&1&1&1\\
\hline
1&1&1&1\\
\hline
1&1&1&1\\
\hline
\end{tabular}}
{\caption{captionB.}
\label{labelB}}
\end{floatrow}
\end{table}%
Some more text some more text some more text some more text some more text some more text some more text.
\end{document}
答案2
我能想到的最基本的解决方案是使用单一table
环境,并将两个tabular
环境及其各自的\caption
和\label
语句放在单独的minipage
环境中。
\documentclass{article}
\begin{document}
\begin{table}
\footnotesize % better than "\fontsize{8}{8}\selectfont"
\begin{minipage}{0.48\textwidth}
\centering
\caption{caption1}
\label{label1}
\begin{tabular}{|c|c|c|c|}
\hline
and&this&is&something\\
\hline
1&1&1&1\\
\hline
1&1&1&1\\
\hline
1&1&1&1\\
\hline
1&1&1&1\\
\hline
\end{tabular}
\end{minipage}
\hspace*{\fill} % note: no blank line between the minipages
\begin{minipage}{0.48\textwidth}
\centering
\caption{caption2}
\label{label2}
\begin{tabular}{|c|c|c|c|}
\hline
and&this&is&something\\
\hline
1&1&1&1\\
\hline
1&1&1&1\\
\hline
1&1&1&1\\
\hline
1&1&1&1\\
\hline
\end{tabular}
\end{minipage}
\end{table}
\end{document}