9

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?

lockstep
  • 250,273
Denis
  • 591
  • 2
    Torbjørn points to the correct way, so putting it back into place after loading babel. If you use a modified class anyway you could also change \appendixname to \customappendixname in the class file so that it will not get modified after you load the class. I am not aware of a write-protect switch though. – Alexander May 12 '13 at 17:14

1 Answers1

11

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.

David Carlisle
  • 757,742
  • 3
    Until someone changes the language using \selectlanguage ... – Heiko Oberdiek May 12 '13 at 18:38
  • @HeikoOberdiek, Torbjørn offered a solution based on this: http://tex.stackexchange.com/questions/82993/how-to-change-the-name-of-document-elements-like-figure-contents-bibliogr (I don't know why he removed his comment). Being combined with the solution from David, it allows to define command for several languages at once. – Denis May 12 '13 at 22:32