Just look at the output below and I think it's obvious what my problems are:
- The wrapped Figure crashed into the lstlistings
The caption didn't notice the huge amount of space to its left that it could use...(Already answered in an answer below)
These kind of things really make me hate LaTeX, nothing seems to work out of the box...please change my mind by showing me an easy way to solve this without the need of a thousand codelines and custom commands :D
Here's the MWE code, keep in mind: I'm looking for a generic solution for images of different sizes, so only making the caption to span across less lines is not enough - that's a seperate problem.
\documentclass[
11pt,
a4paper,
final,
twoside=false,
openright
]{scrbook}
\usepackage{listings,graphicx,wrapfig,xcolor}
\newcommand\crule[3][black]{\textcolor{#1}{\rule{#2}{#3}}}
\begin{document}
\section{Robots}
\begin{wrapfigure}{r}{0.3\textwidth}
\crule{0.25\textwidth}{5cm}
\caption{The UR5 robot arm used in this thesis has 8 links and 6 joints (not including its attached robot hand)}
\end{wrapfigure}
Possession her thoroughly\footnote{Blablabla} remarkably terminated man continuing. Removed greater to do ability. You shy shall while but wrote marry. Call why sake has sing pure. Gay six set polite nature worthy. So matter be me we wisdom should basket moment merely. Me burst ample wrong which would mr he could. Visit arise my point timed drawn no. Can friendly laughter goodness man him appetite carriage. Any widen see gay forth alone fruit bed.
Remain lively hardly needed at do by. Two you fat downs fanny three. True mr gone most at. Dare as name just when with it body. Travelling inquietude she increasing off impossible the. Cottage be noisier looking to we promise on. Disposal to kindness appetite diverted learning of on raptures. Betrayed any may returned now dashwood formerly\footnote{Blablabl2a}. Balls way delay shy boy man views. No so instrument discretion unsatiable to in.
\begin{itemize}
\item Defining constants
\begin{lstlisting}[language=XML]
<xacro:property name="constant_name" value="1" />
<!--Usage - "1" will be inserted below on evaluation-->
${constant_name}
\end{lstlisting}
\item Doing calculations
\begin{lstlisting}[language=XML]
${1+(height/2)}
\end{lstlisting}
\item elebrated is in. Am offended as wandered thoughts greatest an friendly. Evening covered in he exposed fertile to. Horses
\begin{lstlisting}[language=XML]
<xacro:include filename="path_to_file" />
\end{lstlisting}
\end{itemize}
\end{document}
EDIT
I found a trick for the caption issue in another answer: Not writing anything in the caption, breaking the line and then putting the caption text below...but I'm still hoping for a better (but still short!) answer, because I don't want the caption to start in the next line:
\caption{\unskip}
<Caption text here>


\begin{wrapfigure}{r}{0.5\textwidth}work for you (aesthetically)? I for one, find it more appealing to the eye. – naphaneal Jun 09 '18 at 09:47lstlistingenvironments are disabled. If you want to enable them, you can add the optionbreaklinesto the correspondinglstlistingenvironments. – leandriis Jun 09 '18 at 11:10listingscode overlapping with the wrapfigure's caption, the problem of combiningwrapfigurewithitemizestill persists. A discussion on how to solve this can be found here: Will it ever be possible to use wrapfig with an enumerate or itemize environment? – leandriis Jun 09 '18 at 12:53