# How to force text and figures to be on the same page when minipage, samepage, nopagebreak do not work

I'm trying to get four figures (centered on a page in a 2x2 grid) to show up on the same page as the section heading ("Appendix").

The following puts the word "Appendix" on one page (all by itself) and then the four figures on their own page.

I've messed with \nopagebreak, \begin{samepage}...\end{samepage}, \begin{minipage}...\end{minipage} with no luck.

\bibliographystyle{plain}
\bibliography{sid}
\vfill\eject
\appendix
\begin{figure*}
\centering
\subfigure[]{
\includegraphics[height=150pt]{./figs/jjj.png}
\label{fig:jjj}
\subfigure[]{
\includegraphics[height=150pt]{./figs/xxx.png}
\label{fig:xxx}
\subfigure[]{
\includegraphics[height=150pt]{./figs/nnn.png}
\label{fig:nnn}
\subfigure[]{
\includegraphics[height=150pt]{./figs/aaaa.png}
\label{fig:aaa}
\caption{blah  }
\label{fig:aaaa}
\end{figure*}


The \vfill\eject business is to get the word "Appendix" to appear at the top of a new page, not right after the bibliography. BTW, \appendix has this entry in the cls file:

 \def\appendix{\par
\section*{APPENDIX}
\setcounter{section}{0}
\setcounter{subsection}{0}
\def\thesection{\Alph{section}} }

-
Rather than \vfill\eject, just use \newpage. LaTeX will only put a figure* at the top of a page. Try the H option as Ian suggested. In general, if you tell a figure to float, it will float. If you don't want that, try any of the solutions you can find by searching this site for floating graphics. –  TH. Apr 6 '11 at 0:32

Obviously, in this case, you don't want your figures to float, so the natural approach would be not to use float environments. You can use minipages to properly align your subfigures, and using the \captionof command provided by the caption and subcaption packages you can give a caption to your subfigures and to your figure, allowing corresponding labels for cross-references. Here's a little example:

\documentclass{book}
\usepackage{caption}
\usepackage{subcaption}
\usepackage[demo]{graphicx}

\begin{document}

\appendix

\noindent\begin{minipage}{\textwidth}
\begin{minipage}{.5\textwidth}
\centering
\includegraphics[height=150pt]{./figs/jjj.png}
\captionof{subfigure}{First subfigure.}
\label{fig:jjj}
\end{minipage}%
\begin{minipage}{.5\textwidth}
\centering
\includegraphics[height=150pt]{./figs/xxx.png}
\captionof{subfigure}{Second subfigure.}
\label{fig:xxx}
\end{minipage}\\
\begin{minipage}{.5\textwidth}
\centering
\includegraphics[height=150pt]{./figs/nnn.png}
\captionof{subfigure}{Third subfigure.}
\label{fig:nnn}
\end{minipage}%
\begin{minipage}{.5\textwidth}
\centering
\includegraphics[height=150pt]{./figs/aaaa.png}
\captionof{subfigure}{Fourth subfigure.}
\label{fig:aaa}
\end{minipage}
\captionof{figure}{A figure with four subfigures.}
\label{fig:aaaa}
\end{minipage}

\end{document}


I added the demo option to the graphicx package in order to make my example compilable for everyone; do not use that option in your actual code.

As a side note, you seem to be using the subfigure package; this package is obsolete and shouldn't be used anymore; you can use the subcaption package instead.

-

I think this has something to do with the fact that you are using figure*. Normally you can use the [H] option provided by the float package.

\begin{figure}[H]
...
\end{figure}


will force the figure to exactly where it appears in the input file. However, starred figures can only appear at the top of a page, or on their own page.

-