2

I have two tables that are virtually identical and look like so:

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

I know that these tables on their own aren't best practice, but what are the best practices for placing two tables like this, assuming I'm stuck with them, beside each other?

3
  • Welcome to TeX.SX!
    – Ruben
    Commented Dec 5, 2014 at 1:26
  • You should use the floatrow package, it's designed for that.
    – Bernard
    Commented Dec 5, 2014 at 1:30
  • \fontsize{8}{8}\selectfont will typically produce uneven line spacing, for almost all fonts you want the baselineskip to be at least a bit bigger than the font size. why not \footnotesize (which is 8pt in most 10pt class options) Commented Dec 5, 2014 at 9:05

2 Answers 2

0

Here is an illustration of the use of the floatrow package:

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

enter image description here

4
  • This worked perfectly, thanks! Is there a way to prevent the captions from becoming 'compressed' on top of the table though? I'm noticing longer captions wrap around rather than going straight across while centered.
    – user67471
    Commented Dec 8, 2014 at 0:55
  • @user67471: I'm not sure I understand your problem. Do you mean captions should remain one-lined, even if they're very long?
    – Bernard
    Commented Dec 8, 2014 at 1:28
  • Sorry for the late reply Bernard, that was what I meant.
    – user67471
    Commented Dec 16, 2014 at 2:01
  • @user67471: I give a solution in your new question.
    – Bernard
    Commented Dec 16, 2014 at 12:19
2

The most basic solution I can think of is to use a single table environment and to place the two tabular environments, along with their respective \caption and \label statements, in separate minipage environments.

enter image description here

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .