Tx · LaTeX & TikZ

Fix “Control sequence \not= already defined” in MacTeX 2019

Published By the 9to5Science editorial team

At a glance

  1. 1. Find the definition

    Check the log to see which package was loading when LaTeX reported that \not= already existed.

  2. 2. Test a minimal file

    Compile a short document with only the document class and the math packages you need.

  3. 3. Remove conflicts

    Use one math-font setup; with unicode-math, do not also load legacy math-font packages such as amssymb.

  4. 4. Align TeX versions

    Update or reinstall MacTeX as a complete distribution, and check that your editor uses its TeX binaries.

The message LaTeX3 Error: Control sequence \not= already defined. says that LaTeX3’s definition check found an existing definition for the item it was trying to define. The printed text \not= is not a single TeX control sequence: TeX tokenizes it as \not followed by =. In a macro definition, = may be part of the parameter text, so the diagnostic can concern a definition written for the \not= input form. The precise conflicting definition depends on which package or user code triggered it.

The error alone does not identify which package caused the second definition. A common place to investigate is the combination of math-symbol or math-font packages, especially if the document uses unicode-math alongside older packages. The fix is to identify the duplicate definition and make the package setup consistent; changing LuaTeX settings is usually not the answer.

Find where the error occurs

Look in the .log file for the error and the package-loading messages immediately before it. LaTeX often prints a line such as (./some-package.sty) as it reads a package. The last package named before the error is a useful lead, though it may not be the package that originally defined \not=.

Also check the document preamble for repeated package loads and for overlapping math setups. For example, unicode-math provides Unicode math-font support and supplies math symbols. It should not normally be combined with legacy math-font packages such as amssymb or amsfonts. amsmath, which provides mathematical environments and alignment tools, is commonly used with unicode-math and is a different kind of package.

Test a minimal document

Temporarily reduce the document to its class and essential math packages. If you intend to use LuaLaTeX with unicode-math, try this structure:

\documentclass{article}
\usepackage{amsmath}
\usepackage{unicode-math}
\setmathfont{Latin Modern Math}

\begin{document}
\(a \ne b\)
\end{document}

Compile it with LuaLaTeX. If this works, add the original packages back one at a time, compiling after each addition. The package that makes the error return, or the interaction between the last two additions, narrows down the conflict. If the minimal document fails too, check whether the installation itself is consistent and whether the log identifies a package version or file path you did not expect.

If you are not using unicode-math, remove it from the test and use the math packages appropriate to your chosen engine and font setup. Avoid loading two packages that both provide or replace the same math symbols or fonts.

Check which MacTeX installation is being used

MacTeX 2019 contains a dated TeX Live distribution. A common source of confusing package errors is running an editor against one TeX installation while files or updates come from another. Check the executable and package paths in Terminal:

which lualatex
lualatex --version
kpsewhich unicode-math.sty
kpsewhich expl3.sty

The paths should belong to the TeX distribution you intend to use. If you have installed a newer MacTeX, confirm that your editor uses the newer TeX binaries as well; restarting the editor may be necessary. Mixing package files from different TeX Live releases can produce inconsistent definitions.

For an old MacTeX release, the safest general repair is to install a current MacTeX distribution and use it consistently, rather than copying individual package files into the old installation. A package update within TeX Live 2019 does not turn it into a current TeX Live release. If you need to keep the old distribution for a specific project, keep its packages and binaries together and avoid manually mixing in newer files.

Common mistakes

  • Treating this as a LuaTeX syntax error. LuaTeX may be the engine in use, but the message is about a duplicate macro definition during package loading.
  • Loading unicode-math with legacy math-font packages. Use one math-font and symbol setup. With unicode-math, do not also load amssymb or amsfonts unless you have checked that the combination is supported and necessary.
  • Suppressing the error by forcing a redefinition. Redefining or undefining \not, or changing a package’s \not= macro definition, can hide the conflict while leaving symbol behavior unpredictable. Find which package owns the definition instead.
  • Updating only one package file by hand. A mixture of files from different TeX Live releases can create further errors. Keep the distribution consistent.

If the error persists in a minimal example, the useful details to inspect are the full log around the error, the complete package list, the output of lualatex --version, and the paths returned by kpsewhich. Those details distinguish a package conflict from a mismatched TeX installation.

References

  1. The unicode-math package
  2. The LaTeX3 Project

Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.