14

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}

2 Answers 2

15

\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

2

I was having the same problem. When I added amsthm I noticed it clashed with newtxmath. My solution was reordering the packages.

Original (Fails)

\documentclass{minimal}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage{libertine}
\usepackage[libertine]{newtxmath}  % <---- A

\usepackage{amsthm}                % <---- B

\newtheorem{lemma}{Lemma}

\begin{document}
\begin{lemma}
Foo
\end{lemma}
\end{document}

Results in error:

! LaTeX Error: Command \openbox already defined.
               Or name \end... illegal, see p.192 of the manual.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.427   \vrule\hfil}}

Reordered (Works)

\documentclass{minimal}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage{amsthm}                % <---- B

\usepackage{libertine}
\usepackage[libertine]{newtxmath}  % <---- A

\newtheorem{lemma}{Lemma}

\begin{document}
\begin{lemma}
Foo
\end{lemma}
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .