TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top


% Pass any options to the underlying class.
  \PassOptionsToClass{\CurrentOption}{article} % (could be another class)

% Options for this class.
  \def\contentsname{Blarg, blarg, blarg}%

% Defaults.

% Now execute any options passed in

% Load underlying class.

LaTeX complains when the article class tries to define \contentsname:


When I try to load the class before doing my options-processing, LaTeX of course complains.

What's my best way around this? Ideally, I'd like to stick as much to my original idea as possible, because I'm sure there's a much better way to do what I'm trying to do (like figuring out how to harnest Babel, etc.).

share|improve this question
Welcome to TeX.sx! Note that the first two lines of each question is shown on the question list and therefore questions should not start with code but with a short summary. – Martin Scharrer Jul 1 '11 at 17:29
up vote 7 down vote accepted

You shouldn't define macros which the article class later also defines. Either these are overwritten again anyway or an "macro already defined" error is thrown. You need to delay these modifications to after the base class is loaded. In general this is done by only modifying an if-switch in the option code and later execute some code only if this switch is true:

\newif\ifmyclass@myoption% false at first

   code active only for this option

In your specific case I would simply use \AtEndOfClass:

  \AtEndOfClass{\def\contentsname{Blarg, blarg, blarg}}%
share|improve this answer
Thank you very much: \AtEndOfClass is exactly what I needed! – Jérémie Jul 1 '11 at 17:44

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.