3

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}
  • It's not the same. As I make clear, the figure skips onto the next page. The figure does, however, appear below the semicolon (albeit on the next page). So they are distinct problems, actually. – user65526 Aug 7 '15 at 10:04
  • As your example doesn't load the graphics package the image skips to neither page. Beside this: Make the graphic smaller so that it fits on the first page. – Ulrike Fischer Aug 7 '15 at 10:07
  • Do you mean \usepackage{graphicx} ? I have just included it. The image is the size I want it to be. I think it could fit below the semicolon. I just need to know how to force it to appear on the same page without changing the size. – user65526 Aug 7 '15 at 10:08
  • 1
    Well, please first try to reduce the size to something very small. If it works then, Ulrike was right. You may want to load the package \usepackage{showframe} in order to get some guidance when increasing the size of the image again. We can not reproduce your issue by the given code... sorry. – LaRiFaRi Aug 7 '15 at 10:11
  • 2
    Then your graphic has probably large margin. Use \fbox{\includegraphics ...} to see the real size. You can then use the trim key to remove the margins. – Ulrike Fischer Aug 7 '15 at 10:27
1

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

  • This doesn't seem to work (I altered the width in many ways to check). Perhaps I should use \fbox{\includegraphics ...} to see the size of the image and then use the trim key, as Ulrike Fischer suggested. But I don't know how to do this. – user65526 Aug 7 '15 at 10:49
  • @user65526 I added the example. If you have a PDF (here it's a JPG), you can use pdfcrop. – egreg Aug 7 '15 at 10:54
  • trim=1cm 15cm 1cm 1cm worked perfectly! As for producing it using a proof package, the problem is that I am constrained to use two proof packages that seem to have elements of the syntax in common, which causes it to crash. So I'm just taking images of the relevant proofs instead! – user65526 Aug 7 '15 at 10:55
1

To illustrate, what we (Ulrike Fischer, LaRiFaRi. Egreg and me) said in comment:

enter image description here

This I obtained width slightly modified your code (I don't use float package, for image I use example-image:

\documentclass[12pt,a4paper]{article}
\usepackage{graphicx,float}
%\usepackage{float}% it is not necessary, 
                   % avoid placement [H] if it is possible

   \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]
\centering%usually is on begining of environment where ti should act
\includegraphics[width=10cm,scale=18]{example-image}
\end{figure}
And one more figure, with `width=10cm, without `scale` option:
\begin{figure}[h]
\centering
\includegraphics[width=10cm]{example-image}% instead example image I 
                                           % include snip of figure 
                                           %as you updated in your question
\end{figure}

But use only scale: it can not be fit into page ...
\begin{figure}
\centering
\includegraphics[scale=18]{example-image}
\end{figure}
    \end{document}

Test of this code will show, what happens, when the figure is to large ...

Edit: Just to show, that comments of OP is not valid, I cut it from full page with snipping tool image, which she/he provide in upgraded question:

enter image description here

and include it into my MWE. I can be clearly seen, that this image is in the same page. If this is not the case at OP, then only what I can conclude, that original image is bigger as it is or in the real case is something what is not shown in my or egreg answer.

  • Unfortunately none of those solutions seem to work for me. – user65526 Aug 7 '15 at 10:37
  • @user65526 No reason for a downvote. Zarko tried to help you here and spend his time gratis. What does "none seem to work" mean. Please be more specific. What problems do you get with which solution? – LaRiFaRi Aug 7 '15 at 10:41
  • All of the solutions put the image on the next page. So far \begin{comment} \begin{figure}[H] \includegraphics[width=5cm]{prooftreeseqmg2.pdf} \centering \end{figure} \end{comment} produces the best result. – user65526 Aug 7 '15 at 10:44

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.