0

I'm trying to make a document on Overleaf that includes pictures. I have the text and then (after having uploaded the picture) I include the code for a picture and write some more text after. Let's say, I want my pdf to look like TEXT A - picture - TEXT B. I also want my picture to be of size 12cm.

I have the following extract of my document then:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[greek,english]{babel}
\usepackage{alphabeta}
\usepackage{amsfonts}
\setlength{\parskip}{0.5em}
\usepackage{amsmath}
\usepackage{subcaption}
\usepackage{graphicx}
\graphicspath{ {c:/user/Desktop/images/} }
\usepackage{wrapfig}
\usepackage{fullpage}
\usepackage{amssymb}
\usepackage{mathtools}
\usepackage{multicol}
\usepackage{tikz}
\usepackage[bb=boondox]{mathalfa}

\title{--} \author{--} \date{--}

\begin{document}

\maketitle

τον έτρεξα στο command window και το αποτέλεσμα που πήρα ήταν: % this is TEXT A

\begin{figure}[htp] \centering \includegraphics[width=12cm]{cmdw.png} % this is my image \end{figure}

δηλαδή: $$\frac{||x^{(15)}-x||}{||x||}\leq 6.8406\cdot 10^{-15}$$ % this is TEXT B and the end of the subsection

When I run this by itself in a new document, it works just fine and it has the structure TEXT A - picture - TEXT B.

Now, when I run it on my assignment document I have this specific problem: when the picture is 12cm as I want it, it won't fit in the margin that's left at the bottom of the page. So, when I compile it, the picture shows after TEXT B! If I use 8.5cm it fits in the margin, so it has my desired structure.

Also, when I use \quad commands for enough rows, so that the picture starts on the next page, it does appear with my desired structure of TEXT A - picture - TEXT B, but I was wondering if I can avoid using \quad and have the picture just show where I have it in my code! How can I make it so that it always appears where I write it?

David Carlisle
  • 757,742
Tita
  • 157
  • 4
  • 1
    the purpose of the figure environment is to specify a float that may be moved and re-inserted to help with page breaking, so what you describe is the expected behaviour – David Carlisle Dec 28 '21 at 17:43

1 Answers1

2

Quick fix, I do not have much time right now. (Not sure if I understand your question 100 %).

  1. Add \usepackage{float}
  2. Change \begin{figure}[htp] to \begin{figure}[H].

For further reference, see here or here for example.