I'm creating a software guide where I use enumerated list for the steps. Many of the steps have a screenshot I display under the item. I'd like to keep the item and the following figure or graphic together. I've tried Samepage, which does not work. I've also tried minipages, which works but complicates the enumerated list. I'd have thousands of minipages if I did use it. My solution thus far was to add manual pagebreaks or clearpage. I'd prefer code so I don't have to continually edit the manual breaks.
MWE
\section{Section Name}
\begin{enumerate}
\item Directions go here
\FloatBarrier \begin{figure[!h]
\centering\includegraphics[scale=0.65]{ImageA.png}
\end{figure} \FloatBarrier
\item Next step in directions.
\FloatBarrier \begin{figure[!h]
\centering\includegraphics[scale=0.65]{ImageB.png}
\end{figure} \FloatBarrier
\item Step three.
\FloatBarrier \begin{figure[!h]
\centering\includegraphics[scale=0.65]{ImageC.png}
\end{figure} \FloatBarrier
\end{enumerate}
Best Answer
You need not have
\includegraphics
within afigure
environment. In particular, if you want to place images inline within the text, you might as well use thecenter
environment:Note that this, on its own, simply makes it easier to place the images but it does not prevent a page breaks between the text and the
center
environment. If you really want to force them being together, there are two options: either use thesamepage
environment, or define a new\par
that prevents a page break (taken from this answer). Both are illustrated below: