确定超额金额的价值

确定超额金额的价值

如果我将内容放入一个不够宽的框中(0pt在下面的 MWE 中),控制台中会显示一条溢出消息。我可以获得消息中报告的最大值吗?

\hbox 过满(XXXXX 太宽)

将内容排版成\savebox

下面,我手动设置

\setlength{\OverfullSize}{77.16191pt}

并正在寻找一种方法来获取报告的实际值XXXXX

在此处输入图片描述

笔记:

代码:

\documentclass[fleqn]{article}
\usepackage{mathtools}

\usepackage{printlen}
\uselengthunit{pt}

\usepackage{varwidth}
%% https://tex.stackexchange.com/questions/394778/align-in-varwidth-seems-to-ignore-fleqn-option
\makeatletter\let\@vwid@eqmodetrue\@vwid@eqmodefalse\makeatother


\newsavebox{\TempSavebox}
\newcommand*{\DetermineOverfullSize}[2]{%
    \savebox\TempSavebox{%
        \begin{varwidth}{0pt}%
            #2%
        \end{varwidth}%
     }%
     \setlength{\OverfullSize}{77.16191pt}% <-- How to determine the max overfull \hbox?
     \usebox{\TempSavebox}\par%
}

\newcommand*{\MyContentA}{%
\begin{align*}
    y &= mx + b \\
    F &=ma
\end{align*}%
}

\newcommand*{\MyContentB}{%
\begin{align*}
    y &= mx + b \\
    \shortintertext{and}
    F &=ma
\end{align*}%
}


\newlength{\OverfullSize}
\begin{document}
\DetermineOverfullSize{\OverfullSize}{\MyContentA}
\hrule
Above box is overfull by: \printlength{\OverfullSize},

\DetermineOverfullSize{\OverfullSize}{\MyContentB}
\hrule
Above box is overfull by: \printlength{\OverfullSize}
\end{document}

相关内容