# How to force hyphenation in floating figure caption?

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

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.

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.

• You can insert manual hyphenation patters on a case-by-case basis using this\-is\-my\-very\-long\-word\-with\-out\-breaks. – Werner Oct 22 '13 at 17:39
• The code you provided isn't an "MWE", in particular, it doesn't work out of the box, which lowers the chance that you get an answer. And to your question, normally babel helps. – ftfish Oct 22 '13 at 17:41
• As I mentioned, both words hyphenate fine elsewhere in the text, so the question is not about adding hyphenation patterns, or telling LaTeX, where a word may be separated. Rather, I'd like to force a hyphen at an exact position. But thanks anyway. – Chris2013 Oct 22 '13 at 18:01
• @user1931751: Then why don't you just use EA-\\DOGM-LCDs? I guess I don't understand what "forcing a hyphen" means. – Werner Oct 22 '13 at 18:05
• ah, valid point. I have uploaded an image to show what it should look like. Ignore the different font size. But as you can see, I'd like to force LaTeX to set the hyphen within "Abmessungen". – Chris2013 Oct 22 '13 at 18:26

## 2 Answers

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}


• Thanks, the RaggedRight would of course help to compress the text into a narrow column, but I want to have justified text. Updated the post with a second image. – Chris2013 Oct 22 '13 at 18:27
• the second image is easy to realize. See my edit. – user2478 Oct 22 '13 at 18:39
• well, I'd like to think so. See my 2nd edit, since it works flawlessly with a previous wrapfigure, it must be something quirky. – Chris2013 Oct 23 '13 at 6:40
• sorry, but creating a minimal example with your configuration is easy! – user2478 Oct 23 '13 at 6:53
• bear with me, it's my first Tex document. – Chris2013 Oct 23 '13 at 7:40

Alright, I believe to have found the cause and a working solution. According to this the first word of a paragraph never gets hyphenated. Seems to be the same problem with narrow columns in tables.

In order to trick LaTeX, one simply inserts a zero-width \hspace{} before the first word. The caption renders just fine with the following command (note that there is no space between the closing bracket of hspace and the first word:

\caption[...]{\hspace{0pt}Unterschiedliche Abmessungen der EA-DOGM-LCDs.}


Of course, one could define a macro to replace the original command, maybe like so:

\newcommand{\Caption}[2][]{\caption[#1]{\hspace{0pt}#2}}
\Caption{This is the caption text.}
\Caption[This goes into lof]{This still is the caption.}