TransWikia.com

LaTeX seems to ignore `hbt!` float

TeX - LaTeX Asked by somia on March 30, 2021

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.2linewidth}
    includegraphics[width=linewidth]{fig1.jpg}
    caption{fig1}
  end{subfigure}
  begin{subfigure}[b]{0.2linewidth}
    includegraphics[width=linewidth]{fig2.jpg}
    caption{fig2}
  end{subfigure}
  begin{subfigure}[b]{0.2linewidth}
    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.2linewidth}
    includegraphics[width=linewidth]{fig4.jpg}
    caption{fig4}
  end{subfigure}
  begin{subfigure}[b]{0.2linewidth}
    includegraphics[width=linewidth]{fig5.jpg}
    caption{fig5}
  end{subfigure}
  begin{subfigure}[b]{0.2linewidth}
    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.2linewidth}
    includegraphics[width=linewidth]{fig7.jpg}
    caption{fig7}
  end{subfigure}
  begin{subfigure}[b]{0.2linewidth}
    includegraphics[width=linewidth]{fig8.jpg}
    caption{fig8}
  end{subfigure}
  begin{subfigure}[b]{0.2linewidth}
    includegraphics[width=linewidth]{fig9.jpg}
    caption{fig9}
  end{subfigure}
  caption{figures}
  label{fig:third_environment}
end{figure}

One Answer

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.5baselineskip}
begin{figure}[p]
begin{minipage}{textwidth}
  centering
  begin{subfigure}[b]{0.2linewidth}
    includegraphics[width=linewidth]{fig1.jpg}
    caption{fig1}
  end{subfigure}quad
  begin{subfigure}[b]{0.2linewidth}
    includegraphics[width=linewidth]{fig2.jpg}
    caption{fig2}
  end{subfigure}quad
  begin{subfigure}[b]{0.2linewidth}
    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.2linewidth}
    includegraphics[width=linewidth]{fig4.jpg}
    caption{fig4}
  end{subfigure}quad
  begin{subfigure}[b]{0.2linewidth}
    includegraphics[width=linewidth]{fig5.jpg}
    caption{fig5}
  end{subfigure}quad
  begin{subfigure}[b]{0.2linewidth}
    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.2linewidth}
    includegraphics[width=linewidth]{fig7.jpg}
    caption{fig7}
  end{subfigure}quad
  begin{subfigure}[b]{0.2linewidth}
    includegraphics[width=linewidth]{fig8.jpg}
    caption{fig8}
  end{subfigure}quad
  begin{subfigure}[b]{0.2linewidth}
    includegraphics[width=linewidth]{fig9.jpg}
    caption{fig9}
  end{subfigure}
  caption{figures}
  label{fig:third_environment}
end{minipage}
end{figure}
end{document}

Answered by Mico on March 30, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP