I compile using lualatex (2023, Linux) but I believe this is a general question that
also applies to pdflatex:
In my usage situation, a horizontal overfull badbox is indeed bad. So there are overfull rules, messages in the log file, and I can even use the wonderful lua-typo package when needed.
But what I want to do is simply count the number of overfull horizontal lines. This is in running text (possibly also footnotes), but not equations, tables, or graphics. If there are no badboxes, good. If there is at least one, I want to provide a prominent message, reminding the user to look at the log file. If I can get the count of badboxes, then I know how to create the message. In this MWE, instead of a prominent message, it simply types the count:
\documentclass{article}
%\usepackage{fontspec} % Uncomment if compiling with lualatex
\newcounter{hoverfulls}
% This is the kind of code I seek:
%%%%% \AtOverfullHorixBadbox{\addtocounter{hoverfulls}
\AtEndDocument{\typeout{Detected \value{hoverfulls} overfull lines.}}
\begin{document}
LaTeX puts me to sleep, zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\par
But expl3 makes me scream eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\par
\end{document}
Expected message: Detected 2 overfull lines.
How to get the count? Surely it can be done somehow, since TeXworks (and presumably other GUI) can do it. But I use command line.
just run$ grep -c 'Overfull \hbox' file.log` and it will return a count – David Carlisle Mar 13 '24 at 23:36grepis trivial (for me). But I am trying to make it in-your-face for less experienced users. – rallg Mar 13 '24 at 23:39