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}

  • Please prepare a complete and compilable minimal working example (MWE) that others can use to reproduce the output you get. – leandriis Sep 05 '21 at 06: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 Sep 05 '21 at 06: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 Sep 05 '21 at 06:16
  • Some off-topic comments about the code already provided: Using the center environment to horizontally center contents inside of a table environment will lead to additional white space. You may want to replace it with the \centering command. Also, what's the point of tabularx here? A simple \begin{tabular}{lr} should work perfectly fine for this type of tables. For improved and uniform spacing around captions, I'd also load the caption package and remove all occurences of \bigskip. – leandriis Sep 05 '21 at 06:18
  • 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 Sep 05 '21 at 06:23
  • @leandriis The issue is that I cannot seem to have them beside each other and, at the same time, under the same section. – Bored Comedy Sep 05 '21 at 06:32
  • a minitable is positioned by the same code that positions a letter such as X if you use XXX they touch, if you use X X X they have space between and go side by side or wrap to the next line if they do not fit and if you go X blank line X blank line X then they are in three paragraphs so stack vertically. – David Carlisle Sep 05 '21 at 07:43
  • 1
    FloadBarrier will do nothing if used inside a table and will do nothing to adjust the positions of minipages within a table. – David Carlisle Sep 05 '21 at 07:45
  • Is it sensible for minipages that are 0.3 \textwidth to contain tables that are 075 \textwidth? – Bernard Sep 05 '21 at 08:01
  • @Bernard but the inner textwidths are different (they are the width of the minipage) – David Carlisle Sep 05 '21 at 08:07
  • @DavidCarlisle: I thought \textwidth always referred to the document \textwith. So this was a wrong thought? – Bernard Sep 05 '21 at 08:13
  • @Bernard it is the specified width inside a minipage (that's really the origin of the name, it acts like a smaller page, unlike \parbox that just boxes its content. – David Carlisle Sep 05 '21 at 08:17
  • Thank you very much for this clarification! – Bernard Sep 05 '21 at 08:27

1 Answers1

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}

David Carlisle
  • 757,742
  • 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 – David Carlisle Sep 05 '21 at 08: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? – Bored Comedy Sep 05 '21 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 – David Carlisle Sep 05 '21 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. – Bored Comedy Sep 05 '21 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. – David Carlisle Sep 05 '21 at 16:11