Is this something similar to what you'd like to get?
\documentclass{article}
\usepackage{microtype}
\usepackage{kantlipsum}
\begin{document}
\kant[1]
\newbox\mylongbox
\setbox\mylongbox=\vbox{
\hsize=0.7\textwidth
\kant[2-4]
}
\noindent\parbox[t]{0.2\textwidth}{%
Blah blah blah,
blah blah blah blah blah blah blah,
Blah blah blah blah,
}%
\newbox\myspltbox % do a vsplit
\setbox\myspltbox=\vsplit\mylongbox to 0.5\textheight
\hskip0.1\textwidth\vtop{\unvbox\myspltbox}
\moveright0.3\textwidth\box\mylongbox
\end{document}
If you add
\showboxdepth3
\showboxbreadth10
\tracingonline1
to see which box is underfull you see
\hbox(178.66272+0.0)x188.21371
.\hbox(0.0+0.0)x0.0
.\hbox(178.66272+0.0)x187.69623
..\special{ps: currentpoint currentpoint translate 1 1 scale neg exch neg exch
t\ETC.}
..\hbox(178.66272+0.0)x0.0, glue set - 187.69623fil
...\hbox(178.66272+0.0)x187.69623 []
...\glue 0.0 plus 1.0fil minus 1.0fil
..\special{ps: currentpoint currentpoint translate 1 1 div 1 1 div scale neg ex
c\ETC.}
.\glue(\rightskip) 0.0
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
)
\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_decimal_in_unit:nn { #2 } { 1 #1 } cm
}
\ExplSyntaxOff
%\showoutput
\showboxdepth3
\showboxbreadth10
\tracingonline1
\begin{document}
\begin{figure}[htbp]
\centering
\begin{subfigure}[b]{.45\textwidth}
%\centering
\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}
\centering
\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
You get the
Underfull \vbox
message when TeX is doing the\vsplit
: it wants to build a\vbox to 2cm
, but it has to use a break point that doesn't produce a 2 cm high box. You correctly do\setbox0=\vbox{\unvbox0}
, but the underfull box has already been produced.This will tell TeX not to warn for the underfull box, but do the same computations as before. If your computations are performed in a group, then set
\vbadness
to 10000 (or\@M
, which is the same) and forget about it.Note. Box registers 1, 3, 5, 7 and 9 should be used only for global assignments. Not every package conforms to this recommendation, however.