1

I would like to have some paragraphs including a sequence of figures (no text at all). However I am not succeeding in placing the figures right below the paragraph title. What happens is that the paragraph title is shifted below the figures instead of remaining on top of those.

enter image description here

I know from this answer that I should not use a floating environment (such as the figure one) if I do not want my object to float in the document. However I need to organize my images in the same way I would do with the figure and subfigure environments. I have also tried using the H option, but it does not work. How can I achieve that?

Below a MWE for my case.

enter image description here

\documentclass[a4paper,12pt]{article}

\usepackage{float}    % Images formatting
\usepackage{graphicx} % Insert figures
\usepackage{subcaption}

\begin{document}
\paragraph{\boldmath$N=16$}

\begin{figure}[H]
\begin{subfigure}[b]{0.5\textwidth}
   \centering
   \includegraphics[height=0.55\textwidth]{example-image-a}
\end{subfigure}%
\begin{subfigure}[b]{0.5\textwidth}
   \centering
   \includegraphics[height=0.65\textwidth]{example-image-b}
\end{subfigure}
\caption{Illustration 1 of $N=16$}
\label{fig:ill1n16}
\end{figure}

\end{document}
  • 1
    This is enough: newpage\paragraph{$\bm{N=16}$} \leavevmode \begin{figure}[H] ..... – Bernard Feb 10 at 18:50
  • 1
    I've taken the liberty of editing your code to make it truly minimal -- no need to have 6 figure environments over 2 pages if a singe \paragraph statement and a single figure environment will do too, right? – Mico Feb 10 at 19:02
  • 1
    @Bernard - You should post the \leavevmode suggestion as an answer -- and maybe provide an insight as to how and why \leavevmode "works" here? – Mico Feb 10 at 19:04
  • @Mico thanks for the suggestion, indeed a single figure environment does the job for the problem I was facing. – Francesco Feb 10 at 21:03
3

The figure or table envitonment require to be in horizontal mode. Immediately after a \paragraph or \subparagraph command, you're in vertical mode. The \leavevmode command ensures you're no more in vertical mode, and if you add it in your code, lie this:

\paragraph{\boldmath$N=16$}
\leavevmode
\begin{figure}[H]
 .........

it will work.

  • 1
    You wrote, "Immediately after a sectioning command, you're in vertical mode." This is a bit too broad -- the \paragraph and \subparagraph commands appear to require \leavevmode for the problem at hand, whereas \section, \subsection, and \subsubsection do not. – Mico Feb 11 at 0:44
  • Do not use the [H] float positioning parameter. See [HEINOUS]{tex.stackexchange.com/questions/469880} – Peter Wilson Feb 11 at 20:38
  • @PeterWilson: I know, but in the present case, I think it's inevitable considering the OP's requirements, so I respected his/her code. – Bernard Feb 11 at 21:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.