LaTeX Latex help needed, about text between 2 images

AI Thread Summary
The discussion centers on the challenge of positioning text between two images in LaTeX. The original code places the text before the first image and after the second, which is not the desired layout. Several attempts to resolve the issue, including using the float package and adjusting spacing, were unsuccessful. The problem was temporarily "fixed" by adding more text earlier in the document, which inadvertently positioned the images and text correctly. However, this is not a sustainable solution, as it may change with document edits. The conversation highlights that the first image is treated as a float, while the text is part of the document flow. A suggested solution is to combine all elements into a single figure environment with a comprehensive caption that includes all three images, addressing potential issues with figure listings by using an optional argument for the caption.
fluidistic
Gold Member
Messages
3,929
Reaction score
272
Latex "help" needed, about text between 2 images

I'm having troubles to place a text between 2 images.
The code looks like this:

Code:
\begin{figure}[ht]
\begin{minipage}[b]{0.45\linewidth}
\centering
\includegraphics[width=\textwidth]{vvalue}
\caption{value1}
\label{test1}
\end{minipage}
\hspace{0.0cm}
\begin{minipage}[b]{0.45\linewidth}
\centering
\includegraphics[width=\textwidth]{wvalue}
\caption{value2}
\label{test2}
\end{minipage}
\end{figure}

Some text here.

\centerline{\includegraphics[scale=0.36, resolution=900]{test126}}

What is displayed is: "Some text here", then the first image and then the last image. I would like the "Some text here" to be placed in between the two images.

I have tried google and some suggestions, such as using \usepackage{float} and adding an "[H]" at the end of the \centerline line.
Also tried \par \bigskip in between the two images. No luck so far.
 
Physics news on Phys.org
Problem "fixed".
I added more text prior to this part of the document in such a way that now the images and the text are displayed in the middle of a page. The text is now "magically" displayed between the 2 images...
 
fluidistic said:
Problem "fixed".
I added more text prior to this part of the document in such a way that now the images and the text are displayed in the middle of a page. The text is now "magically" displayed between the 2 images...
That's not a good fix. Add more text elsewhere and the problem will reappear. Your first figure is a figure: It's a float. It goes where LaTeX thinks it should go. Your second figure is not a figure. It's just part of the document. It goes where you put it.

Aside: It looks like you are using cargo cult techniques with your LaTeX. Why do you have two captions for that figure environment?

There are a number of ways to "fix" this problem. I'd suggest making the whole enchilada one big "figure". Make a long descriptive caption that describes all three images that comprise the figure. It's common to have very long captions. This might create a new problem if you have a list of figures in your front matter. That long, descriptive caption looks out of place in the list of figures. Use the optional argument to caption to fix this new problem:

\caption[Short title]{Short title. Detailed description of what's shown …}\label{fig:fig42}
 

Similar threads

Replies
5
Views
4K
Replies
3
Views
6K
Replies
3
Views
2K
Replies
5
Views
3K
Replies
5
Views
6K
Replies
4
Views
3K
Replies
7
Views
4K
Back
Top