[Tex/LaTex] Line break in caption of wrapfigure

captionswrapfigure

I use the wrapfigure package for placing images in my text at the right side.

Now my problem is, that my image is really small and my caption is larger then the image.
Instead of a line break at the end of the line it adds the chars below each other.
This looks like the following:

Error on wrapfigure package

So is it possible to add a line break after "Abbildung 4.3:" with the content of \caption?

My code looks like this:

\begin{wrapfigure}{R}{2,76cm}
\includegraphics[]{./bilder/mockup-endtimeError}
\caption{Error Start- Endzeit}
\label{mockup-endtime-error}
\end{wrapfigure}

BR & Thanks,
mybecks

Best Answer

You can use the caption package to format the way the captions are displayed. Yo can also use the ragged2e package to set your caption as ragged right to avoid bad hyphenations.

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{wrapfig}
\usepackage{caption}
\usepackage{lipsum}
\usepackage{ragged2e}
\DeclareCaptionFormat{myformat}{#1#2\\#3}
\captionsetup[wrapfigure]{name=Figure, justification=RaggedRight, format=myformat}
\begin{document}
\begin{wrapfigure}{R}{2,76cm}
\rule{3cm}{5cm}
\caption{Error Start- Endzeit}
\label{mockup-endtime-error}
\end{wrapfigure}

\lipsum

\end{document}

For such small images, I would recommend you use Fig. rather than the full Figure or the equivalent in German. For more details see the caption manual Section 4.1 Further examples.

Related Question