Faça a compilação do LaTeX abortar se o bibitem estiver usando

Faça a compilação do LaTeX abortar se o bibitem estiver usando

Como fazer com que a compilação do LaTeX seja abortada se \bibitem estiver sendo usado? Abaixo está um trecho de código que desejo que a compilação falhe.

\documentclass{article}
\usepackage{amssymb,longtable,amsmath,booktabs,url,amstext,array,geometry}

\begin{document}
\cite{notes}
\cite{notes2}

\begin{thebibliography}{1}
\bibitem{notes} John W. Dower {\em Readings compiled for History 21.479.}  1991.
\end{thebibliography}
\end{document}

Responder1

Conforme observado nos comentários, é melhor usar bibtex ou biber para gerar a bibliografia, no entanto, o latex avisa no final do documento sobre quaisquer citações ou referências indefinidas e você pode facilmente cometer um erro em vez de um aviso, se desejar:

\documentclass{article}
\usepackage{amssymb,longtable,amsmath,booktabs,url,amstext,array,geometry}

\makeatletter
\def\G@refundefinedtrue{%
  \gdef\@refundefined{%
    \GenericError{}{}{There were undefined references}{you wanted an error}}}
\makeatother
\begin{document}
\cite{notes}
\cite{notes2}

\begin{thebibliography}{1}
\bibitem{notes} John W. Dower {\em Readings compiled for History 21.479.}  1991.
\end{thebibliography}
\end{document}

com o acima, a saída do terminal mostra:

! .

There were undefined references
Type  H <return>  for immediate help.
 ...                                              

l.16 \end{document}

? h
you wanted an error
? 

informação relacionada