[Tex/LaTex] How to force hyphenation in floating figure caption

captionshyphenation

I have a right floating figure with a justified caption spanning four lines like so:

what it looks like what it should look like

Unfortunately, LaTeX will not hyphen the words in the caption (both words hyphen just fine in regular text), although just from eye measure there seems to be more than enough space. I have tried adding the words to the \hypenate command, adding soft hyphens "- and separating a word manually, i.e. "Un- terschiedliche". None worked.

I tried increasing the width of the wrapfigure, still nothing (left image below). In another wrapfigure (right image below) it seems to work just fine, and the only difference is caption text and width of both the image and the figure itself.

more wrapfigure width - nothing different image - WORKS!

Is there a way to force LaTeX to hyphen at a particular syllable? Are there penalties for adding Text after a caption name/number?

Code of the first float:

\begin{wrapfigure}{r}{0.25\textwidth}
    \centering
    \includegraphics[width=0.2\textwidth]{images/4_eadogm_footprints}
    \caption[Unterschiedliche Abmessungen der EA-DOGM-LCDs]{Unterschiedliche Abmessungen der EA-DOGM-LCDs.}
    \label{fig:4_eadogm_footprints}
    \vspace{-10pt}
\end{wrapfigure}

I realize without an MWE it is next to impossible to determine my error. I'm using this template and have unfortunately no idea how to compose an MWE with all settings intact.

Any help would be greatly appreciated.

UPDATE: Uploaded image to show what it should look like, rendering with {0.33\textwidth} and working image.

Best Answer

with babel use

\caption[Unterschiedliche Abmessungen der EA-DOGM-LCDs]{%
         Unterschiedliche Abmessungen der EA"=DOGM"=LCDs.}

or at least:

\caption[Unterschiedliche Abmessungen der EA-DOGM-LCDs]{%
         Unterschiedliche Abmessungen der EA-DOGM"=LCDs.}

That should always be done for german texts when you have a word with a hyphen. And also for small text columns use package ragged2e and \RaggedRight for the captions. Can be set automatically with \captionsetup and package caption.

As lon gas you didn't provide a complete example it is really difficult to say what's the problem. This works:

\documentclass[ngerman,a4paper]{book}
\usepackage{libertine}
\usepackage{microtype}
\usepackage{babel}
\usepackage{geometry}

\usepackage{blindtext}
\usepackage[demo]{graphicx}
\usepackage{wrapfig}
\setcounter{chapter}{4}
\setcounter{figure}{11}
\begin{document}

\begin{wrapfigure}{r}{0.25\textwidth}
    \centering
    \includegraphics[width=0.2\textwidth]{images/4_eadogm_footprints}
    \caption[Unterschiedliche Abmessungen der EA-DOGM-LCDs]{Unterschiedliche Abmessungen der EA"=DOGM"=LCDs.}
    \label{fig:4_eadogm_footprints}
    \vspace{-10pt}
\end{wrapfigure}
\blindtext

\end{document}

enter image description here

Related Question