[Tex/LaTex] How to disable \renewcommand

incompatibilitymacros

I've got a custom class derived from report. I defined some standard commands inside of it to reflect its specific, so they look like:

\newcommand\contentsname{Custom Content}
\newcommand\bibname{Custom Bibname}
\newcommand\appendixname{Custom Appendix}

The problem is, when I add inputenc and babel packages which I also need, these commands become overridden with their localized versions from these packages. Of course, I can redefine the commands again in the document preamble, but I'm just curious: is there a general way to define commands which cannot be redefined later with \renewcommand in other classes?

Best Answer

Not really but you can delay your definitions hopefully after anyone else so that you win.

Your class file can use

\AtBeginDocument{%
\renewcommand\contentsname{Custom Content}%
\renewcommand\bibname{Custom Bibname}%
\renewcommand\appendixname{Custom Appendix}%
}

so then the (re)definitions will not happen until the end of the preamble. Of course other packages may delay their definitions too, so you still have to be careful of loading order.

Related Question