[Tex/LaTex] Clash between newtxmath and amsthm packages

amsthmnewtxmath

I'm writing a document with a book structure using only these few packages:

\documentclass[letterpaper, 10pt, oneside]{book}
\usepackage{XCharter}
\usepackage[xcharter]{newtxmath}
\usepackage[cal=boondox,scr=boondox,bb=boondox,frak=euler]{mathalfa}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{amsthm}
\usepackage{mathtools}
\usepackage{enumerate}

I wanted to use the proof environment from the amsthm package, but it produces the following error: Command \openbox already defined. \vrule\hfil}}. I noted that, although my LaTeX editor didn't throw any preview of the document, there is in fact a .pdf file generated, and it compiled just fine.

I began to comment some of the previous packages I use, just to debug and see what caused the problem. If I comment \usepackage[xcharter]{newtxmath}, then the warning disappears.

By the error and the answer given in this question, it is clear that both newtxmath and amsthm are defining a command called \openbox at the same time. What can I do to solve this error? I really don't want to get rid of the newtxmath package nor the XCharter fonts, I love them.

Thank you very much in advance. I provide a MWE:

\documentclass[letterpaper, 10pt, oneside]{book}
\usepackage{XCharter}
\usepackage[xcharter]{newtxmath}
\usepackage[cal=boondox,scr=boondox,bb=boondox,frak=euler]{mathalfa}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{amsthm}
\usepackage{mathtools}
\usepackage{enumerate}

\newcommand{\Ccal}{\mathcal{C}}
\newcommand{\Pcal}{\mathcal{P}}

\begin{document}
    Suppose $\Omega = \{0,1\}$ and $\Ccal = \{\{0\}\}$. Enumerate $\aleph$, the class of all $\sigma$-fields containing $\Ccal$.
    \begin{proof}
        There are just two $\sigma$-fields on $\Omega$: the trivial one $\{\emptyset, \Omega\}$ and the discrete one $\Pcal(\Omega) = \{\emptyset, \{0\}, \{1\}, \Omega\}$. So, $\aleph = \{\Pcal(\Omega)\}$.
    \end{proof}
\end{document}

Best Answer

\openbox is defined by a number of packages

enter image description here

As a quick workaround, you could undefine \openbox before loading amsthm

\documentclass[letterpaper, 10pt, oneside]{book}
\usepackage{XCharter}
\usepackage[xcharter]{newtxmath}
\usepackage[cal=boondox,scr=boondox,bb=boondox,frak=euler]{mathalfa}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\let\openbox\undefined

\usepackage{amsthm}
\usepackage{mathtools}
\usepackage{enumerate}

\newcommand{\Ccal}{\mathcal{C}}
\newcommand{\Pcal}{\mathcal{P}}

\begin{document}
    Suppose $\Omega = \{0,1\}$ and $\Ccal = \{\{0\}\}$. Enumerate $\aleph$, the class of all $\sigma$-fields containing $\Ccal$.
    \begin{proof}
        There are just two $\sigma$-fields on $\Omega$: the trivial one $\{\emptyset, \Omega\}$ and the discrete one $\Pcal(\Omega) = \{\emptyset, \{0\}, \{1\}, \Omega\}$. So, $\aleph = \{\Pcal(\Omega)\}$.
    \end{proof}
\end{document}

enter image description here

Related Question