Graphics, Figures & TablesUsing float in a figure

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
qb170300
Posts: 3
Joined: Sat Mar 08, 2025 10:34 pm

Using float in a figure

Post by qb170300 »

Hi

I have this figure that I want to show sideways because it looks nicer that way. I do this:

Code: Select all

Code, edit and compile here:
\begin{sidewaystable}
\begin{figure}[H]
\centering
\captionsetup{justification=centering}
\includegraphics[scale=.99]{Figures/hbar_pop_auf.pdf}
\end{figure}
\end{sidewaystable}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
However, overleaf puts this figure AFTER some other figures... to avoid that I used the float package:

Code: Select all

Code, edit and compile here:
\usepackage{float}
\begin{sidewaystable}
\begin{figure}[H]
\centering
\captionsetup{justification=centering}
\includegraphics[scale=.99]{Figures/hbar_pop_auf.pdf}
\end{figure}
\end{sidewaystable}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Now the figure appears in the correct order, but I have an annoying word: float .... appearing before the figure.

Does anyone know how to make the word "float" disappear or suggest a better strategy?

thanks

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

Re: Using float in a figure

Post by Stefan Kottwitz »

Welcome to the forum!

That's not caused by the code you showed. See here, and click "Run LaTeX here" to check:

Code: Select all

Code, edit and compile here:
\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{rotating}
\usepackage{caption}
\usepackage{float}
\begin{document}
\begin{sidewaystable}
\begin{figure}[H]
\centering
\captionsetup{justification=centering}
\includegraphics[scale=.99]{Figures/hbar_pop_auf.pdf}
\end{figure}
\end{sidewaystable}
\end{document}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
It's somewhere else in your code, like in a macro redefinition in your preamble. Perhaps show a complete short Infominimal working example.

Stefan
LaTeX.org admin
qb170300
Posts: 3
Joined: Sat Mar 08, 2025 10:34 pm

Re: Using float in a figure

Post by qb170300 »

Thanks, Stefan,

However, I cannot find anywhere else in my code where I use the word ´float´and this issue only occurred when I typed \usepackage{float}... I'll keep thinking about it...

david
User avatar
Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

Re: Using float in a figure

Post by Stefan Kottwitz »

Hi David,

you can follow the "hacking down" procedure from the Infominimal working example explanation (making a copy of your code and reduce it, so it can be posted here without unrelated content) and post the result here. I'm sure that when you post the code that prints 'float', we will find the cause.

Stefan
LaTeX.org admin
qb170300
Posts: 3
Joined: Sat Mar 08, 2025 10:34 pm

Re: Using float in a figure

Post by qb170300 »

Stefan, I found the error!

Instead of using \begin{sidewaystable} I am now using \begin{landscape}. After all, this is a figure, not a table, so I guess latex went crazy not understanding why I was treating a figure like a table. When I do this, everything works nicely!

Code: Select all

Code, edit and compile here:
\begin{landscape}
\begin{figure}[H]
\centering
\captionsetup{justification=centering}
\includegraphics[scale=.99]{Figures/hbar_pop_auf.pdf}
\end{figure}
\end{landscape}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Thanks

David
Post Reply