Yes! In LaTeX, figure placement is influenced by the float mechanism, so using [h!] (here, force) doesn’t guarantee the figure will appear exactly at that point—it’s just a suggestion. If you want the figure to appear right after the section heading, there are a few strategies:
Option 1: Use [H] from the float package
This forces the figure to appear exactly here.
latexCopy code\usepackage{float} % add this to your preamble
User
I don't want any other packages. What else can I do. I added a sentence
Assistant
Got it! If you don’t want to add packages, your options are more limited because LaTeX floats figures by default. Here’s what you can do without extra packages:
Use [h!] with some text
Adding a sentence before the figure often helps LaTeX keep the figure “here” instead of pushing it to the end. For example:
latexCopy code\section{Classification Performance Analysis}
\label{conf_matrices}
User
Maybe scale the figures|
Assistant
Yes! Scaling the figures can help LaTeX fit them immediately after the section instead of pushing them to the end. You can reduce the width so both figures fit nicely on the same page. For example:
latexCopy code\section{Classification Performance Analysis}
\label{conf_matrices}
The classification performance is summarized in the following figures.
\begin{figure}[h!]
\centering
\includegraphics[width=0.8\columnwidth]{latex/belief_confusion_matrix.pdf} % scaled to 80%
\caption{}
\label{fig:belief_matrix}
\end{figure}
\begin{figure}[h!]
\centering
\includegraphics[width=0.8\columnwidth]{latex/practice_confusion_matrix.pdf} % scaled to 80%
\caption{}
\label{fig:practice_matrix}
\end{figure}
You can adjust 0.8\columnwidth to 0.7\columnwidth or smaller if necessary.
Scaling makes it more likely that LaTeX will place them right after the section heading because they take up less vertical space.
Keep the \centering to make them look neat.
If you want, I can suggest a version that puts both figures side by side to save even more space and guarantee they appear immediately after the section. Do you want me to do that?
User
Make them into a single figure, across both columns
Assistant
Perfect! If you want both figures to appear together across both columns in a two-column document, you can use the figure* environment. This spans the figure across the full page width. For example:
latexCopy code\section{Classification Performance Analysis}
\label{conf_matrices}
The classification performance is summarized in the following figures.
\begin{figure*}[h!]
\centering
\includegraphics[width=0.45\textwidth]{latex/belief_confusion_matrix.pdf}
\hspace{0.05\textwidth} % small space between figures
\includegraphics[width=0.45\textwidth]{latex/practice_confusion_matrix.pdf}
\caption{Left: Belief confusion matrix. Right: Practice confusion matrix.}
\label{fig:conf_matrices}
\end{figure*}
✅ Notes:
figure* automatically spans both columns.
Adjust the widths (0.45\textwidth) so the figures fit nicely side by side with a small gap (\hspace).
Use a single caption and a single label for the combined figure.
This will almost always place the figures close to the section heading.
If you want, I can tweak it so the figures are perfectly aligned and fill the width without leaving too much empty space. Do you want me to do that?
Option 2: Place figures inside the section text
Sometimes adding a short paragraph before the figure helps LaTeX “anchor” it in place:
latexCopy code\section{Classification Performance Analysis}
\label{conf_matrices}
The following figures summarize the classification performance:
✅ Recommendation: If you want the figures immediately after the section heading, use [H] with \usepackage{float}. This is the most reliable method.
I also notice you have the same label fig:platform for both figures — you should make them unique (e.g., fig:belief_matrix and fig:practice_matrix) to avoid referencing issues.
If you want, I can rewrite your snippet so both figures appear one after the other right below the section with proper centering and unique labels. Do you want me to do that?
The classification performance is summarized in the following figures.
Adding a line of text like “The classification performance is summarized…” gives LaTeX something to anchor the float to.
Use \clearpage or \newpage
If you really want to force all previous floats to appear before moving on, you can insert:
latexCopy code\clearpage
right after the section heading. It’s more drastic because it can create a page break:
latexCopy code\section{Classification Performance Analysis}
\label{conf_matrices}
\clearpage
Put the figure inline with text
Sometimes wrapping the figure in a paragraph or adding \noindent helps:
latexCopy code\section{Classification Performance Analysis}
\label{conf_matrices}
The first confusion matrix shows belief classification:
\noindent
\begin{figure}[h!]
\centering
\includegraphics[width=\columnwidth]{latex/belief_confusion_matrix.pdf}
\caption{}
\label{fig:belief_matrix}
\end{figure}
💡 Tip: LaTeX will still move figures if it thinks they don’t fit nicely on the page. Adding a sentence before or after usually works best without extra packages.
If you want, I can rewrite your two figures so they almost always appear right after the section heading without any extra packages, using only spacing and text tricks. Do you want me to do that?