哪个 LaTeX 命令会打印有关“Overfull \hbox”的警告消息?

哪个 LaTeX 命令会打印有关“Overfull \hbox”的警告消息?

我想覆盖打印的命令Overfull \hbox...,但似乎不是\GenericWarning。它是什么?

答案1

这来自于 tex 引擎,在经典 TeX 中无法改变。

在 luatex 中有一个回调允许用任意 Lua 代码替换警告,所以在这里我用它来引发 tex 错误。

在此处输入图片描述

\documentclass{article}

\makeatletter
\directlua{
luatexbase.add_to_callback(
"hpack_quality",
function(i,d,h,f,l)
if(i=="overfull") then
tex.error("Overfull line: ".. 
          string.format("\@percentchar.4f",d/65536,3) .. 
          "pt in paragraph lines " ..
           f .. "-" .. l)
end
end,
"error on overfull hbox"
)
}
\makeatother

\begin{document}

One two xxxxxxxxxxxxxx three xxxxxxxxxxxx four
One two xxxxxxxxxxxxxx three xxxxxxxxxxxx four
One two xxxxxxxxxxxxxx three xxxxxxxxxxxx four
One two xxxxxxxxxxxxxx three xxxxxxxxxxxx four
One two xxxxxxxxxxxxxx three xxxxxxxxxxxx four
One two xxxxxxxxxxxxxx three xxxxxxxxxxxx four
One two xxxxxxxxxxxxxx three xxxxxxxxxxxx four
One two xxxxxxxxxxxxxx three xxxxxxxxxxxx four
One two xxxxxxxxxxxxxx three xxxxxxxxxxxx four
One two xxxxxxxxxxxxxx three xxxxxxxxxxxx four
One two xxxxxxxxxxxxxx three xxxxxxxxxxxx four
One two xxxxxxxxxxxxxx three xxxxxxxxxxxx four
One two xxxxxxxxxxxxxx three xxxxxxxxxxxx four
One two xxxxxxxxxxxxxx three xxxxxxxxxxxx four
One two xxxxxxxxxxxxxx three xxxxxxxxxxxx four
One twoxxxxxxxxxxxxxx threexxxxxxxxxxxx four
One two xxxxxxxxxxxxxxthree xxxxxxxxxxxx four
One two xxxxxxxxxxxxxx three xxxxxxxxxxxx four

\begin{quote}
  \rule{12cm}{1cm}
\end{quote}
\end{document}

产生三个错误:

! Overfull line: 5.4100pt in paragraph lines 22-40.
<argument> ...ype:D \tex_hskip:D \c_zero_dim \fi: \tex_par:D 
                                                  \hook_use:n {para/after}\@...

l.40 
   
? 
! Overfull line: 7.9400pt in paragraph lines 22-40.
<argument> ...ype:D \tex_hskip:D \c_zero_dim \fi: \tex_par:D 
                                                  \hook_use:n {para/after}\@...

l.40 
   
? 
! Overfull line: 46.4331pt in paragraph lines 42-43.
<argument> ...ype:D \tex_hskip:D \c_zero_dim \fi: \tex_par:D 
                                                  \hook_use:n {para/after}\@...

l.43 \end{quote}
              
? 

相关内容