Graphics, Figures & TablesStruggling to put Figure at the top of the page

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
kbiren
Posts: 1
Joined: Wed Jun 26, 2024 2:29 pm

Struggling to put Figure at the top of the page

Post by kbiren »

I have an overleaf project with link below. If you go to chapter two (chapter-2.tex), there are two figures. I want to place say the first one at the top of the page i.e. before the paragraph using options like [ht]. Unfortunately, none of the option except [H] is working right now. But [H] would put the figure after the paragraph. If I put other options the figure simply disappears. Please help me!

https://www.overleaf.com/read/pbdhjthhkydp#c4644c (view only)

https://www.overleaf.com/5139396775rftbrwmqwdfb#0e6fa1 (editable)

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX books
User avatar
Stefan Kottwitz
Site Admin
Posts: 10308
Joined: Mon Mar 10, 2008 9:44 pm

Struggling to put Figure at the top of the page

Post by Stefan Kottwitz »

Welcome to the forum!

I tested that Overleaf project. When I replaced the [H] option by [htbp!], I also noticed that the figures disappeared. That's because an error occurs (Too many }'s... \color@endbox ->\color@endgroup \egroup ...), that you can see when you open the error log in Overleaf. That error is the reason.

I see that the template and used style file seems to be more than 20 years old, redefining internal float macros etc. I would not use this template/style myself. If you continue using it, you may keep [H] and carefully place figures and tables in the code. Regarding the figure in chapter 2 you want to move, simply move that figure code above the paragraph in your code while keeping the [H].

Btw. within figure and table environments, use the \centering command instead of \center.

Stefan
LaTeX.org admin
Post Reply