I want to override the command that prints Overfull \hbox..., but it seems that it's not \GenericWarning. What is it?
- 757,742
- 12,021
1 Answers
This comes from the tex egine and in classical TeX can not be changed.
In luatex there is a callback that allows the warning to be replaced by arbitrary Lua code, so here I use it to raise a tex error.
\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}
Produces three errors:
! 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}
?
- 757,742

underfull hboxand flag a non zero exit status if found – David Carlisle Jul 04 '23 at 07:53