0

I am trying to compose a page with a section header and a couple of figures: they should stay on the SAME page, but there is no way to force them to, an extra page is always added between the section and the first figure. Here is the incriminated code:

\subsection{Lipsum} % this works OK
\lipsum[1- 3 ]

\FloatBarrier  % attempt implementing suggestions from this forum
\newpage
\subsection{Graphs}
\begin{figure}[H]
      \centering
      \includegraphics[width=0.5\hsize,height=0.3\vsize,keepaspectratio] {Figures/fig00001.png}
      \\{ Figure 001: Pipponzolo }
\end{figure}

\begin{figure}[H]
      \centering
      \includegraphics[width=0.5\hsize,height=0.3\vsize,keepaspectratio] {../Figures/WashEagle.png}
      \\{ Figure 002: Washington Eagle }
\end{figure}  
\FloatBarrier

the suggestions from Latex Section header and figure won't print on same page did not work.

Wrapping the page between \begin{samepage} and \end{samepage} did not work either.

I am at the end of my rope: any suggestions?

Andrea
  • 1
  • Welcome to TeX.SX! Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. –  Apr 28 '14 at 15:52
  • Welcome to tex.sx, you can use the {} button to format code sections. Please always post a complete document, it is hard to help from a fragment such as the above. since you force a page break before Graphs it seems surprising that you get a page break afterwards (assuming you have loaded the float package to define [H]) – David Carlisle Apr 28 '14 at 15:54
  • 2
    unrelated but don't do \\{ Figure 001: Pipponzolo } try to avoid using \\ outside tables) use \caption{Pipponzolo} – David Carlisle Apr 28 '14 at 15:55
  • you can wrap your block content in a vbox-environment: \begin{vbox} figure1 figure2... \end{vbox} Its content will stay on the same page. – musicman Apr 28 '14 at 16:18
  • @musicman there is no vbox environment in latex (it is not even possible for a contributed package to define such a thing) – David Carlisle Apr 28 '14 at 16:25
  • Hm, strange, it's working here. But \vbox{content} should work. – musicman Apr 28 '14 at 16:31
  • @musicman it can not possibly work (unless you add another explicit { } to specify the content of the box, the environment would just generate a missing { error. Using \vbox would not generate an error but would of course mess up all vertical spacing calculations. – David Carlisle Apr 28 '14 at 16:48
  • David, musicman, Christian, thanks a lot for your time spent on this idiotic problem, and David: I am ashamed of myself, the float package had NOT been loaded, once loaded everything worked allright. Besides pouring ashes on my head, I promise I will be more careful in the future and will in any case provide a complete MWE. Thanks a lot! – Andrea Apr 29 '14 at 08:11
  • Guys, sorry to bother again: am trying to do my honest duty and accept an answer, but it does not seem to allow me to do it: no checkmark to flip. How to? – Andrea May 02 '14 at 07:30
  • @DavidCarlisle I hear you cannot do H without loading float these days ;-) ^^^^ ^ – Johannes_B Oct 17 '15 at 14:24

1 Answers1

3

You need the float package to define the [H] option.

Also it is always better to let latex handle the numbering and caption, so formatting is more consistent and as it knows it is a caption it can then handle cross references and lists of tables, etc.

David Carlisle
  • 757,742