0

I have some simple LaTeX code structured as follows:

  • Introduction
  • Results
  • Discussion

The results section is composed of ten tables. The problem is that the heading (and subsequent text/tables) for the discussion section keep going up and being randomly distributed through the tables in the results. I've been trying to fix this for the past two hours, with some combination of the float package, [H], and vspace, but to no avail. I am working in OverLeaf. Here is the link to my paper: Paper. Any help would be much appreciated.

I also looked at a few other questions and tried implementing their suggestions (\FloatBarrier, placeins , etc.), but to no avail.

Here is some code:

\documentclass[12pt]{article}
\usepackage{multirow}
\usepackage{float}
\usepackage{physics}
\usepackage{siunitx} 
\usepackage{enumerate}
\usepackage{array}
\usepackage{enumitem}
\usepackage[dvipsnames]{xcolor}
\usepackage{tikz}
\usepackage{graphicx,booktabs}

\begin{document}

\title{Very Important Paper} \author{Billy Ards} \date{\today}

\maketitle \section{Introduction} Lorem Ipsum

\section{Results}

\begin{table}[h!]
 \begin{center}
 \begin{tabular}{ c  p{5cm}  p{5cm}  }
 \toprule
  Configuration & Word & Prediction \\ 
\cmidrule(r){1-1}\cmidrule(lr){2-2}\cmidrule(l){3-3}
 \raisebox{-\totalheight}{\includegraphics[width=0.3\textwidth]{B1.png}}
  & 
  stuff in table
  & 
  stuff in table
  \\ \bottomrule
  \end{tabular}
  \caption{$(60,60,60), 60^{\circ}$, P}
  \label{tbl:myLboro}
  \end{center}
  \end{table} 

  \begin{table}[t]
 \begin{center}
 \begin{tabular}{ c  p{5cm}  p{5cm}  }
 \toprule
  Configuration & Word & Prediction \\ 
\cmidrule(r){1-1}\cmidrule(lr){2-2}\cmidrule(l){3-3}
 \raisebox{-\totalheight}{\includegraphics[width=0.3\textwidth]{B2.png}}
  & 
text in table
  &
 text in table
  \\ \bottomrule
  \end{tabular}
  \caption{$(60,60,60), 80^{\circ}$, E}
  \label{tbl:myLboro}
  \end{center}
  \end{table}

  \begin{table}[h]
 \begin{center}
 \begin{tabular}{ c  p{5cm}  p{5cm}  }
 \toprule
  Configuration & Word & Prediction \\ 
\cmidrule(r){1-1}\cmidrule(lr){2-2}\cmidrule(l){3-3}
 \raisebox{-\totalheight}{\includegraphics[width=0.3\textwidth]{B3.png}}
  & 
  text in table
  & 
  text in table
  \\ \bottomrule
  \end{tabular}
  \caption{$(60,60,60), 45^{\circ}$, E}
  \label{tbl:myLboro}
  \end{center}
  \end{table}

  \begin{table}[b!]
 \begin{center}
 \begin{tabular}{ c  p{5cm}  p{5cm}  }
 \toprule
  Configuration & Word & Prediction \\ 
\cmidrule(r){1-1}\cmidrule(lr){2-2}\cmidrule(l){3-3}
 \raisebox{-\totalheight}{\includegraphics[width=0.3\textwidth]{B4.png}}
  & 
  text in table
  & 
  text in table
  \\ \bottomrule
  \end{tabular}
  \caption{$(60,60,60), 30^{\circ}$, E}
  \label{tbl:myLboro}
  \end{center}
  \end{table}

\section{Discussion}

\begin{figure}[H] \centering \includegraphics[width=14cm]{Picture.png} \caption{These are really important.} \end{figure}

enter image description here

rb3652
  • 101
  • Especially the shorter, less upvoted answer (although the accepted answer might explain why you're seeing what you're seeing). Otherwise, you may need to show us some code. – Teepeemm Sep 30 '22 at 17:18
  • @Teepeemm Thank you for the suggestion, but that was one of several answers which I checked (https://stackoverflow.com/questions/1673942/latex-table-positioning, https://tex.stackexchange.com/questions/279/how-do-i-ensure-that-figures-appear-in-the-section-theyre-associated-with, etc.) I'll add some code right now. – rb3652 Sep 30 '22 at 17:22
  • Can you please add the missing parts of your code, starting with \documentclass, \usepackage, ... until \end? This way it can't be copied and compiled. That code should still show your problem. – MS-SPO Sep 30 '22 at 17:48
  • @MS-SPO Sure, thank you for the heads up. You can also take a look at the link to the code, but I'll add the missing parts. – rb3652 Sep 30 '22 at 17:49
  • 1
    But why are you using the table environment at all? The entire point of \begin{table} is to allow TeX to move the table somewhere else. If you don't want the table to move, then you don't need \begin{table}. (Also, your code doesn't give your output.) – Teepeemm Sep 30 '22 at 18:19

1 Answers1

0

I did it! Huzzah! \usepackage[section]{placeins} was the solution! Even though I used it previously, I must have forgotten to add the [section] argument. It works like a charm! Huzzah!

rb3652
  • 101
  • Use of placeins package is not magic wand. It can cause unexpected troubles at formating of your document. For example, in document example showed in question insert a lot of empty spaces ... As the first measure for better place of floats I would change used float place option to [!htbp] and than see, if placein package is really needed. – Zarko Sep 30 '22 at 19:25
  • BTW, You should be aware to uncompatibility of physic and siunitx package. I sudest you to load them as follows: \usepackage{siunitx} \usepackage{physics} \let\qty\SI – Zarko Sep 30 '22 at 19:31