Placing text between pictures

1,520

You use \center{\includegraphics{1}} which (as far as I know) is unknown in LaTeX... so try the following:

\documentclass{article}
    \usepackage{graphicx}

    \begin{document}    
Text 1
\begin{figure}[htb]\centering
\includegraphics[height=0.25\hsize]{example-image-a}
\caption{Figure 1}
\end{figure}

Text 2
\begin{figure}[htb]\centering
\includegraphics[height=0.25\hsize]{example-image-b}
\caption{Figure 2}
\end{figure}

Text 3
\begin{figure}[htb]\centering
\includegraphics[height=0.25\hsize]{example-image-c}
\caption{Figure 3}
\end{figure}
    \end{document}

which should give desired result:

enter image description here

Share:
1,520

Related videos on Youtube

Eugeny89
Author by

Eugeny89

Updated on August 01, 2022

Comments

  • Eugeny89
    Eugeny89 over 1 year

    I'm having the following code

    Text 1
    
    \begin{figure}[h]
    \center{\includegraphics{3}}
    \caption{Figure 1}
    \end{figure}
    Text 2
    
    \begin{figure}[h]
    \center{\includegraphics{1}}
    \caption{Figure 2}
    \end{figure}
    
    Text 3
    
    \begin{figure}[h]
    \center{\includegraphics[width=1\linewidth]{2}}
    \caption{Figure 3}
    \end{figure}
    

    And I suppose it to output something like on the following scheme

    Text 1
    [Figure 1]
    Text 2
    [Figure 2]
    Text 3
    [Figure 3]
    

    But instead of it I'm gettimg

    Text 1
    [Figure 1]
    Text 2
    Text 3
    [Figure 2]
    [Figure 3]
    

    How should I modify my code to get desired result?

    PS. Yes, I saw the question with the same title, but that's not my case.

    • David Carlisle
      David Carlisle almost 8 years
      the only reason to use a figure environment is to allow latex to move it, to help with page breaking, so the output you show is not unexpected. Figures are not part of the main text flow they are floats which are separately positioned. You can of course use \includegraphics directly in the text if that is needed.
  • Eugeny89
    Eugeny89 almost 8 years
    Yes, it works. But height=0.25\hsizeis not enough for me. If I put something like height=0.7\hsize I get the same wrong result
  • egreg
    egreg almost 8 years
    @Eugeny89 What you call a “wrong result” is not wrong. It's just the only way LaTeX has to get the text and the figures in good places so as not to spoil the typesetting. If a figure must go in some place, then it's not a floating object and doesn't have a caption. The caption is exactly what allows for describing the figure in two places: at the reference and under the figure itself.