I want to override the command that prints Overfull \hbox...
, but it seems that it's not \GenericWarning
. What is it?
-
1It is a message from the tex engine.– Ulrike FischerCommented Jul 4, 2023 at 5:58
-
I believed that it can't be override– MadyYuviCommented Jul 4, 2023 at 6:02
-
increase \hfuzz– David CarlisleCommented Jul 4, 2023 at 6:04
-
2@yegor256 I'm afraid that's impossible for pdfLaTeX and XeLaTeX, that message is absolute low-level. Maybe you can hook into something in LuaLaTeX...– SkillmonCommented Jul 4, 2023 at 6:23
-
1tex.stackexchange.com/questions/434830/…– ArneCommented Jul 4, 2023 at 9:38
|
Show 3 more comments
1 Answer
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}
?