# Underfull \hbox warning with \RaggedLeft

I use the mcaption package to place the captions in the margin column. With \RaggedOuter I align them properly on even and odd pages, respectively. Only on even pages, I tend to get underfull \hbox warnings. This happens with \RaggedLeft, but not with \raggedleft. Of course, I rely on the improved version \RaggedLeft because the original one does not even hyphenate particular words when I include \- hints.

Here is my example code:

\documentclass[fontsize=11pt, paper=a4, DIV=classic]{scrbook}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}

\KOMAoption{headinclude}{false}
\KOMAoption{footinclude}{false}
\KOMAoption{mpinclude}{true}
\recalctypearea
\setlength{\marginparsep}{2em}
\setlength{\marginparwidth}{10em}

\usepackage{booktabs}
\usepackage{ragged2e}
\usepackage[top]{mcaption}
\usepackage{blindtext}

\let\RaggedOuter\RaggedRight
\newcommand{\setOddEvenPageLayout}{\ifthispageodd%
{\let\RaggedOuter\RaggedRight}{\let\RaggedOuter\RaggedLeft}}

\addtokomafont{caption}{\RaggedOuter\small}
\setkomafont{captionlabel}{\sffamily\bfseries}
\setcapindent*{0pt}
\renewcommand{\captionformat}{}

\begin{document}

\chapter{Margin captions}

\section{Odd Page}

\blindtext

\begin{table}[h]
\setOddEvenPageLayout
\begin{margincap}
\centering
\begin{tabular}{lll}
\toprule
Test & Test & Test \\
\midrule
Wer & das & liest \\
ist & selbst & schuld \\
\bottomrule
\end{tabular}
\caption{Überblick über die Kontrollstrukturen}
\end{margincap}
\end{table}

\blindtext

\clearpage

\section{Even page}

\blindtext

\begin{table}[h]
\setOddEvenPageLayout
\begin{margincap}
\centering
\begin{tabular}{lll}
\toprule
Test & Test & Test \\
\midrule
Wer & das & liest \\
ist & selbst & schuld \\
\bottomrule
\end{tabular}
\caption{Überblick über die Kontrollstrukturen}
\end{margincap}
\end{table}

\blindtext

\end{document}


What can the the reason for the strange behaviour that only \RaggedLeft, but not \RaggedRight and not \raggedleft produce the warning?

## 1 Answer

You see the same with a simpler example

\documentclass{article}

\usepackage{ragged2e}

\begin{document}

{\RaggedRight

abc

}

{\RaggedLeft

abc

}

\end{document}


with \RaggedRight the last line of a paragraph gets \pafillskip at the right hand side, but \RaggedLeft all lines including the last only get restricted stretch space.

• That means the underfull \hbox warning does not really tell me something. Is there any trick or hack to suppress it? – Matthias Oct 31 '17 at 22:38
• @Matthias not easily. In captions, as they are in a box not on the main vertical list as in my example, you could in theory set it with \parfillskip set to the default \fill glue then the warning would go but the last line of the paragraph would always go flush left then you could use \lastbox to dis-assemble the box and re-position the last line flush right, but it's not easy and rather fragile and might clash with other macros eg color would make it hard, and ignoring the warning in this case is certainly easier. – David Carlisle Oct 31 '17 at 22:42
• Thanks for the quick reply. I would have taken ages to search for a solution since I hate warnings almost as much as errors. But if you tell me to give up I will certainly do so ... – Matthias Oct 31 '17 at 22:44
• @Matthias you could add \hbadness=10000 to your caption code which locally turns off the badness warning just for that paragraph. – David Carlisle Oct 31 '17 at 22:46
• That's a nice idea. Works perfectly. – Matthias Oct 31 '17 at 22:49