today I'm having a problem with one of the chapters of my Thesis. My plan was to define different types of robot arms with a figure in each subsection ( or in my case subsubsection) I wanted the figures to be on left then right then back to left as I go through the subsubsections
\begin{wrapfigure}{r}{0.3\textwidth}
\includegraphics[width=1\linewidth]{Image_directory.png}
\captionsetup{justification=centering,margin=0.1cm}
\caption{Needed_Caption}
\label{fig:wrapfig}
\end{wrapfigure}
The only difference is basically the image file location and caption and {r} or {l} depending on the subsection.
but this is what I got.

Everything is messed up and unreadable and it's giving me old Ms word vibes. anyone can Tell me what I did wrong and nudge me in the right way to fix it? I'm new with Latex so I'm still learning . Thank you for your time and understanding
wrapfigureis fragile and is just like 'Tight' mode in MS Word. You have to either change the contents manually (of course it is hard work) or give upwrapfigurewhere you cannot handle it. Just a normalfigureenvironment will do. – Teddy van Jerry Feb 03 '22 at 15:32\newlinefirst as there is no chance to get an error free layout with them there. But it is impossible to debug code shown as an image, please always try to provide a complete small test document as text in a code block so answers can be tested (you can useexample-imageas the image as it is available for tests) – David Carlisle Feb 03 '22 at 16:10