When compiling the MWE below with pdflatex, I get the warnings Underfull \hbox (badness 10000) in paragraph at lines 26--27
and Underfull \hbox (badness 10000) in paragraph at lines 36--37
.
I tried to avoid this by using \hfill
between the subfigures, but it didn't work.
\documentclass{scrbook}
\usepackage[utf8]{inputenx}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{epstopdf}
\usepackage{subcaption}
\usepackage{gnuplottex}
\usepackage{xparse}
\ExplSyntaxOn
\DeclareExpandableDocumentCommand{\convertlen}{ O{cm} m }
{
\dim_to_unit:nn { #2 } { 1 #1 } cm
}
\ExplSyntaxOff
\begin{document}
\begin{figure}[htbp]
\centering
\begin{subfigure}[b]{.45\textwidth}
\begin{gnuplot}[terminal = cairolatex, terminaloptions = {size \convertlen{\textwidth},\convertlen{.3\textheight}}]
plot sin(x)
\end{gnuplot}
\caption{A subfigure}
\label{fig:1a}
\end{subfigure}%
\hfill
\begin{subfigure}[b]{.45\textwidth}
\begin{gnuplot}[terminal = cairolatex, terminaloptions = {size \convertlen{\textwidth},\convertlen{.3\textheight}}]
plot sin(x)
\end{gnuplot}
\caption{Another subfigure}
\label{fig:1b}
\end{subfigure}
\caption{A figure}\label{fig:1}
\end{figure}
\end{document}
Best Answer
If you add
to see which box is underfull you see
So the line is trying to be 188.21371pt but the box with the plot is 187.69623pt the only glue on the line is
\rightskip
and that is zero, so the box is underful.That's slightly odd as a one line paragraph usually has
\parfillskip
at the end but that has been removed here somewhere in the verbatim handling for gnuplot.rather than debug exactly where
\parfillskip
went, a simpler fix is to make\rightskip
non zero, and if you uncomment the%\centering
the warning goes away.(I updated the name of
\dim_to_decimal_in_unit:nn
)