I have atm1.tex
which used to compile ok. It hasn't changed since last time I compiled it, but its base classes have changed:
! LaTeX Error: Command \text already defined.
Or name \end... illegal, see p.192 of the manual.
How can I find where \text
was already defined?
atm1.tex
contains:
\documentclass[a4paper]{atm}
...
\begin{checklist} % Makes a table where we can add \text, \result, or \action lines
\text{This line contains text}
...
atm.cls
contains:
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{atm}[acceptance test manual template]
\LoadClass{simdoc}
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{simdoc}}
\ProcessOptions\relax
\RequirePackage{textcomp} % Allows use of degree symbol
\RequirePackage[clock]{ifsym} % Brings in \StopWatchStart
...
\newcommand{\text}[1]{& #1 & &\\}
...
and simdoc.cls
contains:
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{simdoc}[Sim International document template]
\LoadClass{report}
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{report}}
\ProcessOptions\relax
\RequirePackage[margin=3cm]{geometry}
\RequirePackage{longtable,array}
\RequirePackage{titlesec}
\RequirePackage[dvipsnames]{xcolor}
\RequirePackage{colortbl}
\RequirePackage{graphicx}
\RequirePackage{fancyhdr}
\RequirePackage{etoolbox}
\RequirePackage[hidelinks]{hyperref}
\RequirePackage{textcomp, booktabs}
\RequirePackage{url}
\RequirePackage{xparse}
\RequirePackage{caption}
\RequirePackage{xcolor}
\RequirePackage{soul}
\RequirePackage [most]{tcolorbox}
\tcbuselibrary{skins}
\usepackage[toc,page]{appendix}
...
Clearly \text
is defined in atm1.cls
, and that's the only one I expected would exist. I suspect someone added a new \RequirePackage
to simdoc.cls
which introduces a new definition for \text
. I could rename \text
to something else, but I have hundreds of documents which inherit from this class (all broken) and thousands of uses of \text
, so I'd rather not change all of them.
I tried changing \newcommand{\text}
to \providecommand{\text}
. It compiles, but it doesn't seem to use atm.cls
's definition of \text
(instead of a \text{Hello}
taking up a line in the table, it overlaps the next line of the table).
I also tried: \let\text\undefined\newcommand{\text}...
. This works, but is it safe? I'm scared about unintended consequences.
If the above idea is not safe, then my question is "how do I know which \RequirePackage
defined \text
?". Knowing this will help me search for alternatives.
\text
is defined inamsmath
, I'd strongly recommend not to redefine it.\text
was defined inamsmath
by memory, or did you figure this out so quickly with a command or search?\span
, hardly anyone knows what it is used for, so it would be obvious to redefine it to be\operatorname{span}
if you're writing about linear algebra. If you do that tables, matrices, align, etc no longer works.\text
has been inamstext
which is loaded byamsmath
for many many years. The only way this has been able to compile is ifamsmath
has never been used.