[Tex/LaTex] Forcing a figure not to skip onto the next page

floatsgraphics

enter image description hereWhen I include the following figure it doesn't go directly below the text after the semicolon but skips onto the next page (it does however appear below the semicolon). The image is the size I want it to be. I just need to know how to force it to appear on the same page without changing the size. How can I force the figure not only to appear below the semicolon in the following example, but force it not to skip onto the next page?

\documentclass[12pt,a4paper]{article} 
\usepackage{float}  
\usepackage{graphicx}

\begin{document} 
  The sequent calculus proof of this uses contraction and is therefore not derivable in linear logic (unless special modalities are used):
\begin{figure}[H]
\includegraphics[width=10cm,scale=18]{prooftreeseqmg2.pdf}
\centering
\end{figure}

\end{document}

Best Answer

Your image is a displayed formula (that could by directly produced with LaTeX, I believe), so treat it as a displayed formula:

\documentclass[12pt,a4paper]{article} 
\usepackage{graphicx}

\begin{document} 
The sequent calculus proof of this uses contraction and is therefore
not derivable in linear logic (unless special modalities are used):
\[
\includegraphics[width=10cm]{prooftreeseqmg2.pdf}
\]

\end{document}

There's no rule that says \includegraphics should be in a figure environment. To the contrary, it can go everywhere: as far as TeX is concerned, the image is just like a big box.

Note that specifying scale=18 and width=10cm is redundant: just use the width; it's probably better to say something like

\includegraphics[width=.7\columnwidth]{prooftreeseqmg2.pdf}

(adjust the factor to your liking).

If the PDF image has white margins, use trim:

\includegraphics[
  clip,
  trim=1cm 8cm 1cm 1cm,
  width=.7\columnwidth,
]{prooftreeseqmg2.pdf}

experimenting what dimensions are the good ones. The trimming lengths are in the order “left–bottom–right—top”.

Using the image you posted, here's the example:

\documentclass[12pt,a4paper]{article}
\usepackage{graphicx}

\begin{document}
The sequent calculus proof of this uses contraction and is therefore
not derivable in linear logic (unless special modalities are used):
\[
\fbox{\includegraphics[
  clip,
  trim=6cm 41cm 3cm 6cm,
  width=10cm]{prooftreeseqmg2}}
\]
Some text after the display.
\end{document}

Remove the \fbox that I just added for debugging.

enter image description here