1

I want three figure environments to be positioned side by side and I tried to add hbt! float to each figure environment to achieve this. However, only the first figure environment is positioned at the right place and the latter two are somehow positioned at next page, with a text of next section being inserted between the first environment and second environment. LaTeX seems to ignore hbt! for the latter two.

How can I three figure environments to be positioned side by side? As long as the three row comes side by side like a table, I don't care the way.

I'll show you a part of my LaTeX code:

my preample:

\documentclass{jsarticle}

\usepackage[dvipdfmx]{graphicx} \usepackage{subcaption} \usepackage{amsmath,amssymb,bm,braket,ascmac}

figure section:

\begin{figure}[hbt!]
  \centering
  \begin{subfigure}[b]{0.2\linewidth}
    \includegraphics[width=\linewidth]{fig1.jpg}
    \caption{fig1}
  \end{subfigure}
  \begin{subfigure}[b]{0.2\linewidth}
    \includegraphics[width=\linewidth]{fig2.jpg}
    \caption{fig2}
  \end{subfigure}
  \begin{subfigure}[b]{0.2\linewidth}
    \includegraphics[width=\linewidth]{fig3.jpg}
    \caption{fig3}
  \end{subfigure}
  \caption{figures}
  \label{fig:first_environmet}
\end{figure}
\begin{figure}[hbt!]
  \centering
  \begin{subfigure}[b]{0.2\linewidth}
    \includegraphics[width=\linewidth]{fig4.jpg}
    \caption{fig4}
  \end{subfigure}
  \begin{subfigure}[b]{0.2\linewidth}
    \includegraphics[width=\linewidth]{fig5.jpg}
    \caption{fig5}
  \end{subfigure}
  \begin{subfigure}[b]{0.2\linewidth}
    \includegraphics[width=\linewidth]{fig6.jpg}
    \caption{fig6}
  \end{subfigure}
  \caption{figures}
  \label{fig:second_environment}
\end{figure}
\begin{figure}[hbt!]
  \centering
  \begin{subfigure}[b]{0.2\linewidth}
    \includegraphics[width=\linewidth]{fig7.jpg}
    \caption{fig7}
  \end{subfigure}
  \begin{subfigure}[b]{0.2\linewidth}
    \includegraphics[width=\linewidth]{fig8.jpg}
    \caption{fig8}
  \end{subfigure}
  \begin{subfigure}[b]{0.2\linewidth}
    \includegraphics[width=\linewidth]{fig9.jpg}
    \caption{fig9}
  \end{subfigure}
  \caption{figures}
  \label{fig:third_environment}
\end{figure}
somia
  • 11
  • 1
    Hi, welcome! figure is a floting environment, if you put your images there they will float. Please read https://tex.stackexchange.com/questions/39017/how-to-influence-the-position-of-float-environments-like-figure-and-table-in-lat – Rmano Mar 24 '21 at 11:33
  • Note that h in that list does not mean here. It means here about with some text above and below. If that is not possible h will be discared. Note that you should always include p in that list to ensure that the figure does not float too far away (like to the end of the chapter because not h, t or b worked for placement). – daleif Mar 24 '21 at 11:53
  • In general never expect a figure to be where you added it in the code and never use on the figure below we see..... Always refer to figure number (using \label and \ref) – daleif Mar 24 '21 at 11:54
  • 1
    floats are never "side by side", you need to put everything in one figure environment for this (e.g. with three minipages there). – Ulrike Fischer Mar 24 '21 at 13:37

1 Answers1

3

To guarantee that the three groups of three images will be placed on a single page, you should use a single figure environment; in it, place three minipage environments, each with three subfigure environments and four \caption directives. I would also increase both the horizontal separation (via \quad or \qquad statements) and vertical separation (via \bigskip directives).

enter image description here

\documentclass[demo]{article} % remove 'demo' option in real doc.
\usepackage{graphicx,subcaption}
\begin{document}
\captionsetup[figure]{skip=0.5\baselineskip}
\begin{figure}[p]
\begin{minipage}{\textwidth}
  \centering
  \begin{subfigure}[b]{0.2\linewidth}
    \includegraphics[width=\linewidth]{fig1.jpg}
    \caption{fig1}
  \end{subfigure}\quad
  \begin{subfigure}[b]{0.2\linewidth}
    \includegraphics[width=\linewidth]{fig2.jpg}
    \caption{fig2}
  \end{subfigure}\quad
  \begin{subfigure}[b]{0.2\linewidth}
    \includegraphics[width=\linewidth]{fig3.jpg}
    \caption{fig3}
  \end{subfigure}
  \caption{figures}
  \label{fig:first_environmet}
\end{minipage}

\bigskip \begin{minipage}{\textwidth} \centering \begin{subfigure}[b]{0.2\linewidth} \includegraphics[width=\linewidth]{fig4.jpg} \caption{fig4} \end{subfigure}\quad \begin{subfigure}[b]{0.2\linewidth} \includegraphics[width=\linewidth]{fig5.jpg} \caption{fig5} \end{subfigure}\quad \begin{subfigure}[b]{0.2\linewidth} \includegraphics[width=\linewidth]{fig6.jpg} \caption{fig6} \end{subfigure} \caption{figures} \label{fig:second_environment} \end{minipage}

\bigskip \begin{minipage}{\textwidth} \centering \begin{subfigure}[b]{0.2\linewidth} \includegraphics[width=\linewidth]{fig7.jpg} \caption{fig7} \end{subfigure}\quad \begin{subfigure}[b]{0.2\linewidth} \includegraphics[width=\linewidth]{fig8.jpg} \caption{fig8} \end{subfigure}\quad \begin{subfigure}[b]{0.2\linewidth} \includegraphics[width=\linewidth]{fig9.jpg} \caption{fig9} \end{subfigure} \caption{figures} \label{fig:third_environment} \end{minipage} \end{figure} \end{document}

Mico
  • 506,678