0

I want to represent 3 tables beside each other under the same section. But whatever I tried to do, \FloatBarrier never seemed to do anything.

Keeping the 3 tables beside each other is done using minipages (as shown by multiple answers on this sight):

\begin{table}
  \begin{minipage}{0.3\textwidth}
    \begin{center}
      \caption{First Trial \label{tab: Table 1}}
      \bigskip
      \begin{tabularx}{0.75\textwidth}{
        >{\raggedright\arraybackslash}X
        >{\raggedleft\arraybackslash}X}
        \toprule
        \(x\) (cm) & \(t\) (s) \\
        \midrule
        100 & 5.66 \\
        90 & 4.81 \\
        80 & 4.34 \\
        70 & 3.26 \\
        60 & 3.00 \\
        50 & 2.79 \\
        40 & 2.27 \\
        30 & 1.69 \\
      \bottomrule
      \end{tabularx}
    \end{center}
  \end{minipage}
  \quad
  % Second trial
  \begin{minipage}{0.3\textwidth}
    \begin{center}
      \caption{Second Trial \label{tab: Table 2}}
      \bigskip
      \begin{tabularx}{0.75\textwidth}{
        >{\raggedright\arraybackslash}X
        >{\raggedleft\arraybackslash}X}
        \toprule
        \(x\) (cm) & \(t\) (s) \\
        \midrule
        100 & 5.66 \\
        90 & 4.81 \\
        80 & 4.34 \\
        70 & 3.26 \\
        60 & 3.00 \\
        50 & 2.79 \\
        40 & 2.27 \\
        30 & 1.69 \\
        \bottomrule
      \end{tabularx}
    \end{center}
  \end{minipage}
  \quad
  % Third trial
  \begin{minipage}{0.3\textwidth}
    \begin{center}
      \caption{Third Trial \label{tab: Table 3}}
      \bigskip
      \begin{tabularx}{0.75\textwidth}{
        >{\raggedright\arraybackslash}X
        >{\raggedleft\arraybackslash}X}
        \toprule
        \(x\) (cm) & \(t\) (s) \\
        \midrule
        100 & 5.66 \\
        90 & 4.81 \\
        80 & 4.34 \\
        70 & 3.26 \\
        60 & 3.00 \\
        50 & 2.79 \\
        40 & 2.27 \\
        30 & 1.69 \\
        \bottomrule
      \end{tabularx}
    \end{center}
  \end{minipage}
\end{table}

Possible unrelated question: Why do the tables stack up on each other when I add a newline between the quads, like this:

% First trial
\begin{table}
  \begin{minipage}{0.3\textwidth}
    \begin{center}
      \caption{First Trial \label{tab: Table 1}}
      \bigskip
      \begin{tabularx}{0.75\textwidth}{
        >{\raggedright\arraybackslash}X
        >{\raggedleft\arraybackslash}X}
        \toprule
        \(x\) (cm) & \(t\) (s) \\
        \midrule
        100 & 5.66 \\
        90 & 4.81 \\
        80 & 4.34 \\
        70 & 3.26 \\
        60 & 3.00 \\
        50 & 2.79 \\
        40 & 2.27 \\
        30 & 1.69 \\
      \bottomrule
      \end{tabularx}
    \end{center}
  \end{minipage}

  \quad

  % Second trial
  \begin{minipage}{0.3\textwidth}
    \begin{center}
      \caption{Second Trial \label{tab: Table 2}}
      \bigskip
      \begin{tabularx}{0.75\textwidth}{
        >{\raggedright\arraybackslash}X
        >{\raggedleft\arraybackslash}X}
        \toprule
        \(x\) (cm) & \(t\) (s) \\
        \midrule
        100 & 5.66 \\
        90 & 4.81 \\
        80 & 4.34 \\
        70 & 3.26 \\
        60 & 3.00 \\
        50 & 2.79 \\
        40 & 2.27 \\
        30 & 1.69 \\
        \bottomrule
      \end{tabularx}
    \end{center}
  \end{minipage}

  \quad

  % Third trial
  \begin{minipage}{0.3\textwidth}
    \begin{center}
      \caption{Third Trial \label{tab: Table 3}}
      \bigskip
      \begin{tabularx}{0.75\textwidth}{
        >{\raggedright\arraybackslash}X
        >{\raggedleft\arraybackslash}X}
        \toprule
        \(x\) (cm) & \(t\) (s) \\
        \midrule
        100 & 5.66 \\
        90 & 4.81 \\
        80 & 4.34 \\
        70 & 3.26 \\
        60 & 3.00 \\
        50 & 2.79 \\
        40 & 2.27 \\
        30 & 1.69 \\
        \bottomrule
      \end{tabularx}
    \end{center}
  \end{minipage}
\end{table}

I thought whitespace didn't matter.


Anyways, as many answers indicate over here, \FloatBarrier from placein could be used in order to keep figures, tables, and other stuff in their desired sections. However, when I add a \FloatBarrier just before I type \end{table}, nothing changes. In fact, wherever I add \FloatBarrier in the table environment, nothing changes. Why doesn't \FloatBarrier have any effect here?

Lastly, how could I keep multiple tables beside each other and under the same section?

EDIT: Sorry for not providing a MWE from the beginning

\documentclass[12pt]{article}
\usepackage{booktabs, tabularx}

\begin{document}
\section{First Section}
The tables below provide data.

% First trial
    \begin{table}
      \begin{minipage}{0.3\textwidth}
        \begin{center}
          \caption{First Trial \label{tab: Table 1}}
          \bigskip
          \begin{tabularx}{0.75\textwidth}{
            >{\raggedright\arraybackslash}X
            >{\raggedleft\arraybackslash}X}
            \toprule
            \(x\) (cm) & \(t\) (s) \\
            \midrule
            100 & 5.66 \\
            90 & 4.81 \\
            80 & 4.34 \\
            70 & 3.26 \\
            60 & 3.00 \\
            50 & 2.79 \\
            40 & 2.27 \\
            30 & 1.69 \\
          \bottomrule
          \end{tabularx}
        \end{center}
      \end{minipage}
      \quad
      % Second trial
      \begin{minipage}{0.3\textwidth}
        \begin{center}
          \caption{Second Trial \label{tab: Table 2}}
          \bigskip
          \begin{tabularx}{0.75\textwidth}{
            >{\raggedright\arraybackslash}X
            >{\raggedleft\arraybackslash}X}
            \toprule
            \(x\) (cm) & \(t\) (s) \\
            \midrule
            100 & 4.43 \\
            90 & 4.10 \\
            80 & 3.44 \\
            70 & 3.32 \\
            60 & 3.12 \\
            50 & 2.54 \\
            40 & 2.33 \\
            30 & 1.56 \\
            \bottomrule
          \end{tabularx}
        \end{center}
      \end{minipage}
      \quad
      % Third trial
      \begin{minipage}{0.3\textwidth}
        \begin{center}
          \caption{Third Trial \label{tab: Table 3}}
          \bigskip
          \begin{tabularx}{0.75\textwidth}{
            >{\raggedright\arraybackslash}X
            >{\raggedleft\arraybackslash}X}
            \toprule
            \(x\) (cm) & \(t\) (s) \\
            \midrule
            100 & 4.95 \\
            90 & 4.75 \\
            80 & 3.71 \\
            70 & 3.64 \\
            60 & 3.19 \\
            50 & 2.47 \\
            40 & 1.88 \\
            30 & 1.31 \\
            \bottomrule
          \end{tabularx}
        \end{center}
      \end{minipage}
    \end{table}
\end{document}
13
  • Please prepare a complete and compilable minimal working example (MWE) that others can use to reproduce the output you get.
    – leandriis
    Commented Sep 5, 2021 at 6:11
  • Did you already try to use the optional argument of the table environment? See also the part about "Float placement specifiers" in the answer to How to influence the position of float environments like figure and table in LaTeX?
    – leandriis
    Commented Sep 5, 2021 at 6:14
  • Since you mention the issue that empty lines between minipages results in stacked instead of side-by-side minipages and even show a corresponding part of code, here: What exactly is the issue here? You already seem to know how to avoid it...
    – leandriis
    Commented Sep 5, 2021 at 6:16
  • 1
    For an improved (more even) horizontal distribution of the individual tables, you may either want to replace \quad with \hfill or add \centering withg before the first minipage environment. (You can add \usepackage{showframe} (draws lines tovisualize the textblock/margins) to the preamble to see the effect.)
    – leandriis
    Commented Sep 5, 2021 at 6:23
  • 1
    FloadBarrier will do nothing if used inside a table and will do nothing to adjust the positions of minipages within a table. Commented Sep 5, 2021 at 7:45

1 Answer 1

3

You have not provided any code that shows the issue but your first code block has a table containing a single paragraph that has

minitable space quad minitable space quad minitable

with the spaces coming from the end of line after \end{minitable}.

Usually a space is around .3em so the total width here is .9\textwidth+ 2.6em so this will fit on one line or wrap to two lines at the second space depending on whether or not .9\textwidth+ 2.6em is less than \textwidth.

Your second table has 3 paragraphs

minitable
paragraph break and discarded horizontal skip
minitable
paragraph break and discarded horizontal skip
minitable

so the three paragraphs appear vertically.

As you see, white space matters in both these cases it is adding inter-word space in the first case and paragraph breaks in the second.

The purpose of the table environment is to allow the content to be moved. You have not said what document class you are using but most default the position to [tbp] which would not allow it to be placed where it is in the source, under a heading, that is the h (here) position so use [htbp] which will then not move the table if it fits under the heading.

enter image description here

\documentclass{article}

\usepackage{tabularx,booktabs}
\begin{document}


\section{Some section}
\begin{table}[htbp]
  \begin{minipage}[t]{0.3\textwidth}
  \centering
      \caption{First Trial \label{tab: Table 1}}
      \bigskip
      \begin{tabularx}{0.75\textwidth}[t]{
        >{\raggedright\arraybackslash}X
        >{\raggedleft\arraybackslash}X}
        \toprule
        \(x\) (cm) & \(t\) (s) \\
        \midrule
        100 & 5.66 \\
        90 & 4.81 \\
        80 & 4.34 \\
        70 & 3.26 \\
        60 & 3.00 \\
        50 & 2.79 \\
        40 & 2.27 \\
        30 & 1.69 \\
      \bottomrule
      \end{tabularx}
  \end{minipage}\hfill
  \begin{minipage}[t]{0.3\textwidth}
   \centering
      \caption{Second Trial \label{tab: Table 2}}
      \bigskip
      \begin{tabularx}{0.75\textwidth}[t]{
        >{\raggedright\arraybackslash}X
        >{\raggedleft\arraybackslash}X}
        \toprule
        \(x\) (cm) & \(t\) (s) \\
        \midrule
        100 & 5.66 \\
        90 & 4.81 \\
        80 & 4.34 \\
        70 & 3.26 \\
        60 & 3.00 \\
        50 & 2.79 \\
        40 & 2.27 \\
        30 & 1.69 \\
        \bottomrule
      \end{tabularx}
  \end{minipage}\hfill
  % Third trial
  \begin{minipage}[t]{0.3\textwidth}
 \centering
      \caption{Third Trial \label{tab: Table 3}}
      \bigskip
      \begin{tabularx}{0.75\textwidth}[t]{
        >{\raggedright\arraybackslash}X
        >{\raggedleft\arraybackslash}X}
        \toprule
        \(x\) (cm) & \(t\) (s) \\
        \midrule
        100 & 5.66 \\
        90 & 4.81 \\
        80 & 4.34 \\
        70 & 3.26 \\
        60 & 3.00 \\
        50 & 2.79 \\
        40 & 2.27 \\
        30 & 1.69 \\
        \bottomrule
      \end{tabularx}
  \end{minipage}
\end{table}
\end{document}
5
  • 2
    note that I would not use tabularx here there is no line breacing, if you use tabular with {rrr} columns so the tables were set their natural widths the x cm would not break over two lines and the numeric data would be alighened even if you had an entry such as 10.12 Commented Sep 5, 2021 at 8:21
  • Thanks for the answer. I will update the code to form a MWE. But may I ask, what does hfill do, and how does it differ from quad? Commented Sep 5, 2021 at 14:01
  • @BoredComedy hfill is a space that stretches as much as necessary so the three tables will be as far apart as possible. \quad is a fixed width of 1em so you are positioning the tables at fixed positions from the left with the right margin being whatever space is left Commented Sep 5, 2021 at 15:50
  • Thanks for the clarification. From where does the argument [tbp] come from? And what's the point of \FloatBarrier then? Sorry if these are amateur questions but I've got some holes in my knowledge of LaTeX. Commented Sep 5, 2021 at 16:07
  • 1
    @BoredComedy tbp is core latex it should be described in any latex tutorial, sorry the site format really doesn't support asking multiple questions as comments on an existing one. FloatBarrier is used in the main document not in table enviornment and stops floats such as tables moving past that point, it is not relevant to the issue as you have described it. Commented Sep 5, 2021 at 16:11

You must log in to answer this question.

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