addmargin, enumerate and align* miss an overfull hbox

The following document compiles as expected, and looks as expected:

\documentclass{article}

\usepackage{scrextend}
\usepackage{amsmath}
\usepackage{lipsum}

\begin{document}
\lipsum[1]

\lipsum[2]

\begin{enumerate}
\item
\lipsum[3]

\item
\begin{align*}
abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmn
\end{align*}
\end{enumerate}
\end{document}


The content of the align* environment overflows the normal text area. However, there is no "overfull hbox" warning. Making the text even longer eventually produces the warning, but it's too late - depending on the nesting, the warning only occurs if the text is shifted far out of the page.

How can I make sure to be warned in such situations?

• It seems to be a bug in the align* environment. If it is changed to equation*, a warning results. I've tried to locate the source of the problem, but the definition is very complicated, so no explanation yet. – Dan Oct 29 '13 at 22:11
• addmargin is irrelevant; the missing warning doesn't depend on it. – egreg Nov 1 '13 at 20:45
• @Dan does the proposed change below look OK? – David Carlisle Sep 3 '17 at 9:13

Update

This has been fixed (using the code below) in release 2.17a of amsmath (August 2017).

amsmath explicitly tests for this situation and adds code to issue a warning

\begin{macro}{\black@}

This macro is made to produce an overfull box message and possibly (depending on the value of \overfullrule) a rule in the margin if the total width of an alignment is larger than the value of \displaywidth.

Unfortunately the code it inserts only produces a warning with fleqn (flush left equations, which is the default for AMS classes) not with the centred equations which is the standard default.

The following fixes that, it should make no change at all in documents without over wide equations. For documents with over wide equations the internal box structure is slightly different but there should be no visible change to the document except in draft mode when as documented above, you get an overfull box rule at the margin.

This will probably appear in the next release of amsmath pending further testing.

As modified below the test file produces console output

Overfull \hbox (49.62772pt too wide) detected at line 38


Test file:

\documentclass{article}

\usepackage{scrextend}
\usepackage{amsmath}

\makeatletter
\def\black@#1{%
\noalign{%
\ifdim#1>\displaywidth
\dimen@\prevdepth
\nointerlineskip
\vskip-\ht\strutbox@
\vskip-\dp\strutbox@
\vbox{\noindent\hbox to \displaywidth{\hbox to#1{\strut@\hfill}}}%
\prevdepth\dimen@
\fi
}%
}
\makeatother

\usepackage{lipsum}

\begin{document}
\lipsum[1]

\lipsum[2]

\begin{enumerate}
\item
\lipsum[3]

\item
\begin{align*}
abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmn
\end{align*}
\end{enumerate}

• Nice to see this fixed – looking forward to seeing this in a future amsmath release! – fefrei Sep 3 '17 at 20:14
• but fleqn is not the default with ams document classes; the default is centered equations. the code surrounding the fleqn definitions is convoluted and not well documented, but it is not the default. – barbara beeton Apr 3 '18 at 15:53