Help in LaTeX- Continuing text after embedding a picture

In summary, the conversation discusses the issue of a picture being placed before the text in a LaTeX document. The proposed solution is to use the \newpage command before embedding the image. However, this is not a recommended solution as it can cause issues with typesetting. The proper use of the figure environment is explained, where the figure is placed close to the reference in the text. The conversation ends with a thank you for the helpful advice.
  • #1
opus
Gold Member
717
131
TL;DR Summary
LaTeX embedded pictures
As you can see in my attached picture, I am trying to continue on with my text after my embedded image, but it is putting the text still before the image. I'm not sure why it's doing this because I am writing the text after the \end{figure} command.
Any ideas?
 

Attachments

  • Screen Shot 2019-06-13 at 4.52.28 PM.png
    Screen Shot 2019-06-13 at 4.52.28 PM.png
    41.1 KB · Views: 540
Physics news on Phys.org
  • #2
This is usually because the picture is too large and it requires space which is only available on the new page. Your picture isn't very detailed so you could probably scale it down to, say half the size. Maybe you also have a big white border which you first can cut.
 
  • Like
Likes opus
  • #3
Thanks fresh. I changed the image to even a very small size and it's still doing it for some reason.
I found this resource
https://www.overleaf.com/learn/latex/Positioning_of_Figuresand have tried the commands that it has given, such as setting the image at the top of the following page etc, but it's not really doing anything. Odd...

Edit: Also trimmed the image to get rid of all excessive border whitespace.
 
  • #4
For example, using the [t!] command isn't even putting the image at the top of the page as it should. And when the image size is changed, it just changes the image and has no effect on the placement.
 

Attachments

  • Screen Shot 2019-06-13 at 6.15.51 PM.png
    Screen Shot 2019-06-13 at 6.15.51 PM.png
    32.6 KB · Views: 448
  • #5
Also tried to get rid of the center command as maybe it put the image directly in the center of the page, not just between left and right, but this didnt help either. Just shifted it to the left.
 
  • #6
Got it. Had to use the \newpage command before embedding the image.
Thanks!
 
  • Like
Likes fresh_42
  • #7
opus said:
Got it. Had to use the \newpage command before embedding the image.
Thanks!
This is a really bad solution as it will mess up your typesetting completely if you decide to write more text in front. The \newpage command should never be used unless you really mean to start a new page. It should certainly not be used for image placement.

You also should not be using the figure environment if you want to put a figure in the actual text for some reason. The figure environment should be used when you want a figure in your document that has a caption and is referred to in the main text through a \ref command. In other words you would write something like
Code:
bla bla bla, see Figure~\ref{fig:1}.
\begin{figure}
...
\caption{}\label{fig:1}
\end{figure}
bleh bleh bleh.
This will produce something like "bla bla bla, see Figure 1. bleh bleh bleh." with the figure being placed conveniently close by default (not on an earlier page than where you put the figure in the code, but on the same page or as soon as possible). This is the reason for writing the figure commands close to the reference.

In your case, you are not showing your entire document so we can only guess at what is going on. However, it is clear that you are making the figure on page 1, which likely has some sort of title. LaTeX is not going to put the figure on the same page as that title because where it would be put is occupied by the title. Placing the figure there would also mean moving the place where it occurs in the source to the next page, which is also not going to happen. Hence, LaTeX places your figure on the next page, regardless of whether it has text or not. When the figure is alone on a page, it is typically centered on that page, which seems to be what is going on in your case.

Note again that the figure environment produces a float (as does the table environment). These are objects that LaTeX is allowed to move around when typesetting and should be referred to in the text (they are not part of the main text!). If you want to place some image in the main text, you can just include it there, preferably in a centered environment or similar.

TLDR; You are not using the figure environment in the way it is intended. It produces a float that is allowed to move around when typesetting your document, not an object that should be placed in the main text.
 
  • Like
Likes opus
  • #8
Oh awesome that is extremely helpful thank you @Orodruin. I was actually a little bit hesitant in adding the picture as I was thinking it was going to turn into a Microsoft Word nightmare where one small change turns the entire document into a mess. You've saved me a great head ache, thank you.
 

1. How do I continue writing after inserting a picture in LaTeX?

To continue writing after embedding a picture in LaTeX, you can use the \afterpage command. This command allows you to specify the content that you want to appear after the current page has been completed, which can include text, images, or any other LaTeX elements.

2. Is it possible to continue text on the same page after inserting a picture?

Yes, it is possible to continue text on the same page after inserting a picture in LaTeX. You can use the \afterpage command to specify the content that should appear after the picture, and then use the \clearpage command to start a new page. This will ensure that the text continues on the same page as the picture.

3. How can I control the placement of the picture and the continued text in my document?

To control the placement of the picture and the continued text in your document, you can use the \begin{figure}[h] command. This will place the picture and the continued text in the same location as specified by the [h] option. You can also use other options such as [t] for top of the page, [b] for bottom of the page, or [p] for a separate page.

4. Can I continue text after multiple pictures in LaTeX?

Yes, you can continue text after multiple pictures in LaTeX by using the same method as mentioned above. You can use the \afterpage command after each picture and then use the \clearpage command to start a new page. This will ensure that the text continues after each picture on the same page.

5. How do I add captions to pictures and continued text in LaTeX?

To add captions to pictures and continued text in LaTeX, you can use the \caption command. This command allows you to add a caption to your picture, and you can also use the \listoffigures command to create a list of all the figures in your document with their corresponding captions. For continued text, you can simply add a sentence or phrase after the \afterpage command to serve as a caption for the continued text.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
355
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
827
  • MATLAB, Maple, Mathematica, LaTeX
Replies
12
Views
801
  • MATLAB, Maple, Mathematica, LaTeX
Replies
9
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
12
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
Replies
11
Views
486
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
1K
Back
Top