1

When using \subref from the subfig package I occasionally encounter an overfull hbox. A MWE is provided below and gives me the following warning:

Overfull \hbox (7.1673pt too wide) in paragraph at lines 16--17

The margin is indeed violated: Margin violation

Does anyone have an idea on how to fix this?

\documentclass{report}
\usepackage[caption=false,subrefformat=parens,labelformat=parens]{subfig}

\begin{document}
\setcounter{chapter}{10}
\chapter{Chapter title}
\begin{figure}[h]
\centering
\subfloat[Subcaption.]{\rule{100pt}{50pt}\label{sfig:sfig1}}
\caption{Caption.}
\label{fig:Fig1}
\end{figure}

sample text sample text sample text sample text sample text saa Figure~\subref*{sfig:sfig1} sample text sample text sample text sample text 
\end{document}

1 Answers1

1

By using Figure~\subref*{sfig:sfig1} the only possible breaking points are to hyphenate "Figure" or to break after the whole expression. With the default settings LaTeX does not do the linebreak by hyphenating "Figure" because then the line would be underful. If you make the spaces a bit stretchier by using \emergencystretch=.5em, the new linebreak will hyphenate "Figure".

Of course this might result in spaces which are larger than desired from a typographical point of few. In this case rephrasing the sentence can avoid the problem.

\documentclass{report}
\usepackage[caption=false,subrefformat=parens,labelformat=parens]{subfig}

\emergencystretch=.5em

\begin{document}
\setcounter{chapter}{10}
\chapter{Chapter title}
\begin{figure}[h]
\centering
\subfloat[Subcaption.]{\rule{100pt}{50pt}\label{sfig:sfig1}}
\caption{Caption.}
\label{fig:Fig1}
\end{figure}

sample text sample text sample text sample text sample text saa Figure~\subref*{sfig:sfig1} sample text sample text sample text sample text 
\end{document}

enter image description here


A small suggestion: With the cleveref package it is not necessary to manually write Figure~:

\documentclass{report}
\usepackage[caption=false,subrefformat=simple,labelformat=simple]{subfig}

\usepackage[capitalise,noabbrev]{cleveref}
\renewcommand{\thesubfigure}{(\alph{subfigure})}

\emergencystretch=.5em

\begin{document}
\setcounter{chapter}{10}
\chapter{Chapter title}
\begin{figure}[h]
\centering
\subfloat[Subcaption.]{\rule{100pt}{50pt}\label{sfig:sfig1}}
\caption{Caption.}
\label{fig:Fig1}
\end{figure}

sample text sample text sample text sample text sample text saa Figure~\subref*{sfig:sfig1} sample text sample text sample text sample text 

sample text sample text sample text sample text sample text saa \cref{sfig:sfig1} sample text sample text sample text sample text 
\end{document}