# Figure captions line breaks

So I'm working on a TeX document and everything's fine until at some point I realize the captions are doing something weird: whenever the caption spans over multiple lines the new lines start after the "Figure xy:" text (see figure below for example).

Now I'm unable to provide any mwe since I have no idea what's causing this and I can't even replicate it myself: I have over 1500 lines of code and I have no idea what I'm looking for to fix this. Any clue or hint is appreciated!

\begin{wrapfigure}{r}{0.5\textwidth}
\vspace{-0.7cm}
\centering
\includegraphics[width=0.5\textwidth]{example-image-a}
\vspace{-0.2cm}
\caption{This was the simplest image to use as example for what is happening to all my captions now, whenever the caption is longer than one line it starts \textit{after} the Figure xy:'' text.}
\vspace{0.2cm}
\end{wrapfigure}
Here there's a bunch of text I'm not including,
which is appearing on the left of the image over half of the linewidth.


In my document my code is causing this:

But when trying to paste the code in a "fresh" document it works just fine:

• What document class are you using? Do you load the caption package or any other package that does something to figures and captions like subfig, subfigure, subcaption? Even in a very long document it should be possible with a bit of work to isolate the issue in a binary search (see tex.meta.stackexchange.com/q/228/35864). The cause is quite probably in the preamble, so you focus on that (verify it by throwing out all text in your document) and then just remove half of the code and check if the output is the same until you have isolated the relevant bits of code. – moewe Mar 10 at 10:48
• The format you describe as works just fine is called plain. The layout you describe as undesired is called hang. Both can be achieved using the caption package. In your original document there might be a line similar to \captionsetup{format=hang} that causes the undesired behaviour. But without a MWE this is just a guess. – leandriis Mar 10 at 10:48
• @Superuser27: As already said, the above was just a guess. There might be other packages or your documentclass that overrides your captionsetup. – leandriis Mar 10 at 10:55
• @Superuser27: The default behaviour might differ from documentclass to documentclass or might also be changed by a certain package you load. But since you added no information about this, there is no way one could tell you which of them causes the observed behaviour. For a description of the plain format, you can have a look at section 2.1 of the caption manual – leandriis Mar 10 at 11:03
• Please -- as usual here -- show us a short compilable tex code resulting in your issue! – Mensch Mar 10 at 11:22

This answer is based upon the following assumpton: In the MWE to this question you use the scrreprt documentclass, so I assume this is also the case here.

Following this assumption, I came up with the following MWE that replicates your issue and contains the above mentioned documentclass as well as the code from your question and the \captionsetup line you mentioned in a comment:

\documentclass{scrreprt}
\usepackage{caption}
\usepackage{graphicx}
\usepackage{wrapfig}
\begin{document}

\captionsetup{format=default,indention=0pt,justification=justified}

\begin{wrapfigure}{r}{0.5\textwidth}
\vspace{-0.7cm}
\centering
\includegraphics[width=0.5\textwidth]{example-image-a}
\vspace{-0.2cm}
\caption{This was the simplest image to use as example for what is happening to all my captions now, whenever the caption is longer than one line it starts \textit{after} the Figure xy:'' text.}
\vspace{0.2cm}
\end{wrapfigure}
Here there's a bunch of text I'm not including,
which is appearing on the left of the image over half of the linewidth.

\end{document}


The result is the following:

If we now change from format=default to format=plain we get the desired result:

If we use the report documentclass in combination with format=default, we obtain the following result:

To find an explanation for the different behaviour when using different documentclasses, we can have a look into the caption manual which tells us about the default settings used in different documentclasses:

You can also achieve the desired result using KOMA-script features rather than the caption package. As we learned from the above shown excerpt of the caption manual, the indentation of caption text in KOMA script classes is done using the \setcapindent command, we can also use this command to achieve a non indented caption text.

\documentclass{scrreprt}
\usepackage{graphicx}
\usepackage{wrapfig}
\setcapindent{0pt}
\begin{document}

\begin{wrapfigure}{r}{0.5\textwidth}
\vspace{-0.7cm}
\centering
\includegraphics[width=0.5\textwidth]{example-image-a}
\vspace{-0.2cm}
\caption{This was the simplest image to use as example for what is happening to all my captions now, whenever the caption is longer than one line it starts \textit{after} the Figure xy:'' text.}
\vspace{0.2cm}
\end{wrapfigure}
Here there's a bunch of text I'm not including,
which is appearing on the left of the image over half of the linewidth.

\end{document}


We can also find a hint to that in the KOMA script manual (section 3.20: 'Floating Environments for Tables and Figures', page 139 of the manual to version 3.26b):

• +1 for the detective work. This answer shows how important an MWE can be to make sure that the question is well-defined. It might be an extreme example of a package exhibiting different default behaviour for different document classes, but this is definitely not unique and these effects can be far more subtle. – moewe Mar 10 at 13:04