0

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.

  • 1
    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. – David Carlisle Nov 14 '15 at 14:03
1

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

  • 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 – Eugeny89 Nov 14 '15 at 14:06
  • 1
    @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. – egreg Nov 14 '15 at 14:17

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.