I can find a tool to convert PDF to EPS
in my neither bathroom nor kitchen.}

$\A$ is my favourite equation and the following is my favourite quote.

Is it OK to define a macro before document class? What is the side effect?

  • 5
    I think it ought to be "neither in my bathroom nor in my kitchen", in other questions and answers of yours as well.
    – doncherry
    Jul 24, 2011 at 22:17
  • 1
    @Harrold: I personally don't care if it's technically correct grammar. It's confusing, especially for non native speakers, and not the usual way to say it Jul 24, 2011 at 22:55
  • 2
    @Martin On this type of website, I do not care about it either – I was just trying to support doncherry. I think that his suggestion is less confusing than the original sentence by xport, who generally seems to be doing easy things the hard way. :-P Jul 24, 2011 at 23:07
  • 1
    @doncherry An example of the same construction: “In her neither too short nor too long career, she has made great revelations.” I normally rather use either + or because the positive e.g. “I can” at the beginning may be misleading in long sentences. Jul 25, 2011 at 12:23
  • 1
    @Harrold. There's nothing to apologize for. Sometimes, English retains strange syntactic constructions from past stages for singular phrases. It's always enlightening to discuss such matters with native speakers and I'm glad we could solve this question. So now, xport could edit her post(s).
    – doncherry
    Jul 27, 2011 at 12:14

3 Answers 3


TeX processes tokens following its rules and \def\A{...} conforms to them. On the other hand defining tokens that way may break depending on what packages are loaded. Even \newcommand might not be sufficient, because packages could define their macros with \def, but in any case macros with the same name at the outer level cannot exist.

One should know what's being done, in other words.

To the contrary, defining macros before \documentclass is a well known practice. Suppose you have a part of your document that you don't want to be processed in certain situations. It can be done by enclosing the part in

<part not to be always included>

(we assume that conditionals are properly balanced in that part). Calling the compilation of the file, named file.tex, with

pdflatex "\def\dontincludethispart{}\input{file}"

will not include the "secret" part. The comment package allows for similar tricks and has been discussed here on TeX.sx.


Yes, it is OK. There is no side effect for macros in general. The class file isn't any special from TeX points of view. However, you shouldn't define or change important macros which are also set in the class at random. You can even load packages before the class when you use \RequirePackage instead of \usepackage. Of course there might be some packages which rely on the fact to be loaded after the class.


Some macros you shouldn't define before the documentclass. Namely, if you wanted to redefine, say \section which is defined by the document class, the redefinition wouldn't work if you put it before the document class.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .