Why is my table before the section title?
I know that it is not a popular solution on this site but I like it anyway.
- The
float
package offers an additional placement parameter/option calledH
. If you use it then the float object (figure or table) is exactly placed where you put it in the code. - Normally you want floating objects to float and let LaTeX decide where to put it.
- But with approach that I describe here, you have full manual control of the float position if you want to.
- You can still combine this approach with the other solutions mentioned here (
flafter
package and!htb
placement parameter). Just decide from table to table (or figure and figure) what is best.
\documentclass{article}
\usepackage{float} % here for H placement parameter
\begin{document}
Text before table.
\begin{table}[H] % placement parameter H
\centering % if you want to center the table
\caption{Table showing \ldots}
\label{table:ExampleTable}
% Code for table
\end{table}
Text after table.
\end{document}
By the way, normally you want to have a little unbreakable space between the number and the unit:
720\,°C
or720~°C
. Where\,
is a half space and~
a full space. See here and here for further information. But this is not related to the question at all.
You need \begin{table}[htp]
in order to allow the figure to appear mid-page (h
).
Also you might want to add
\usepackage{flafter}
which prevents figures ever floating backwards up the current page
So with flafter
(but not h
) the float will appear at the bottom of the current page or top of the next.
With [htpb]
then without flafter
the order that is tried is h
, t
on this page, b
on this page, p
, t
on next page. (But it is t
on this page that you want to avoid).
With [htpb]
then withflafter
the order that is tried is h
, b
on this page, p
, t
on next page.
Use the [!htbp]
option. I also used makecell
and siunitx
to have a nicer formatting of the table, so you don't have to use \resizebox
:
\documentclass[a4paper, french]{report}
\usepackage[utf8]{inputenc}
\usepackage[TS1,T1]{fontenc}
\usepackage{lmodern}
\usepackage{babel}
\usepackage{geometry}
\usepackage{makecell, caption}
\renewcommand\theadfont{\normalsize\bfseries\boldmath}
\usepackage{siunitx}
\sisetup{detect-weight, range-phrase=/, range-units = single}
\usepackage{lipsum}
\renewcommand\thesection{\arabic{section}}
\setcounter{section}{3}
\begin{document}
\subsection{Cinétique d'oxydation des joints de grains avec teneur nominale en chrome}
\lipsum[2]
\begin{table}[!hbt]
\centering\renewcommand{\arraystretch}{1.2}
\caption{Données utilisées pour la calibration de la cinétique d'oxydation des joints de grains présentant une teneur nominale en chrome à \SIrange{320}{325}{\celsius}}
\begin{tabular}{|c|c|c|c|c|}
\hline
\thead{Repère} & \thead{Échantillon} & \thead{pox max & & \\ (nm)} & \thead {Température \\ (\si{\celsius})} & \thead{Temps\\ (h)} \\
\hline
\hline
B356 (TT 1\,h $ \times $ \SI{720}{\celsius}) & 1816-22 & 10 & 325 & 0,16 \\
\hline
T265 & 1866-20 & 307 & 325 & 100 \\
\hline
B356 SA & 1866-187 & 847 & 320 & 1000 \\
\hline
\end{tabular}
\label{tab:calibrecinetique}
\end{table}
\lipsum[3]
\subsection{Cinétique d'oxydation des carbures de chrome}
\lipsum[5]
\end{document}