0

I was writing out a document, and tried to insert the image of a graph. However, the image gets displayed before the text it is placed after. How do I rectify this?

\section{Problem 3}
Find the number of roots of the equation $x+2\tan x=\frac{\pi}{2}$ in the interval $\left[0,2\pi\right]$.
\subsection{Solution}
Rewrite the equation to get
\begin{equation*}
    \tan x=\frac{\pi}{4}-\frac{x}{2}
\end{equation*}
Now let us graph two functions, namely $y=\tan x$ and $y=\frac{\pi}{4}-\frac{x}{2}$ in the interval $\left[0,2\pi\right]$. Their common intersection points give us the exact number of solutions.
\begin{figure}
\centering
\includegraphics[width=0.5\linewidth]{desmos-graph(3).png}
\end{figure}
As we can clearly see, $y=\frac{\pi}{4}-\frac{x}{2}$ is a line with negative slope, and it \textit{will} intersect the graph of $\tan x$. As shown, there will be $\boxed{3}$ solutions.

\includegraphics[width=0.5\linewidth]{desmos-graph(3).png} is the line in which the image is included. However, when I compile my pdf, this is the outcome Something

How do I correct this?

David Carlisle
  • 757,742
  • 2
    figure is a float environment, and that means its content can float away. Don't use it if you don't want it (but be aware that this can lead to lots of white space if you don't let large objects float). See als https://tex.stackexchange.com/a/39020/2388 – Ulrike Fischer Nov 04 '23 at 14:10
  • 1
    that is the only function of the figure environment to allow it to move, \includegraphics would include the image at the point specified – David Carlisle Nov 04 '23 at 14:13
  • Thank you @UlrikeFischer and @DavidCarlisle! I removed the \begin{figure} and it works perfectly fine – Doge with shades Nov 04 '23 at 14:21

0 Answers0