As tomorrow is April 1, I'd like to send a somewhat special interim version of my thesis to my supervisor. In the TeXbook, there is a chapter that is set up to make TeX fall in love with hyphenation. I like how it manages to hyphenate nearly every end-of line.
However, applying this to my document, I ended up with something like this:
\documentclass{article}
\usepackage{graphicx,lipsum}
\usepackage[hang,small,bf]{caption} % not loading this "fixes" my problem
%\captionsetup{singlelinecheck=false} % this also causes the problem to disappear, but I like the singlelinecheck
% handy commands from the TeXbook to apply all the best typographical rules regarding hyphenation
\hyphenpenalty=-1000
\pretolerance=-1
\tolerance=1000
\doublehyphendemerits=-100000
\finalhyphendemerits=-100000
\begin{document}
\begin{figure}
\includegraphics[width=\textwidth,height=1cm]{example-image}
\caption{Figure Caption that Should not Be Hyphenated}
\end{figure}
\lipsum[1]
\end{document}
Note how the text is nice and readable, but the caption is broken at every discetionary hyphen.
Apparently, this is somehow related to the way caption
checks whether the caption fits into a single line and should be centered. Also, if I don't load the package at all, the problem disappears.
Is there a better way to fix this or to configure caption
to use the normal hyphenation settings?
figure
environment, to add\hyphenpenalty=10000 \exhyphenpenalty=10000
.figure
gives a local group, so these settings should not persist outside that environment. (but the same rules wouldn't carry over to a list of figures, if you have one.)\AtBeginEnvironment
for that. I just tested your suggestion and it works.\DeclareCaptionFont{nohyphen}{\hyphenpenalty=10000 \exhyphenpenalty=10000\relax}\captionsetup{font+=nohyphen}
(in the document preamble) should do the trick as well.\let\svcaption\caption \renewcommand\caption[1]{\bgroup\pretolerance=10000\relax\svcaption{#1}\egroup}