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

I have written a class file for my 3rd year project students (despite my lack of expertise!), and I wanted to avoid them having to use the maketitle command.

Here is a minimal example:

The class file:

%\section{Class declaration}
\ProvidesClass{test}[13/06/2012 PC]
% Base this class on KOMA script article class file
% A 5mm binding is added to margin

A tex test example:

\author{PC} % \copyright UEA}
\title{my title}    
A test

This works with the above, but if I uncomment the second line (\usepackage{color}) I get an error:

! Undefined control sequence.
\set@color ...\@pdfcolorstack push{\current@color 
                                              }\aftergroup \reset@color 
l.10 \begin{document}

I am using the latest installation of TeXLive (installed today). Any explanation as to what is happening, and if there is a way of solving the problem?

share|improve this question
up vote 5 down vote accepted



color package uses \AtBeginDocument to set this but as the package is loaded after the class it gets set too late, so just set it a bit earlier.

share|improve this answer
So would another option be to \RequirePackage{color} in the class file, before \maketitle is thrown in there? (Just for my continuing education.) – Sean Allred Jun 20 '13 at 16:46
@SeanAllred yes except that would force colour in to the document and (might?) create option class errors if the document wants to use xcolor or something. – David Carlisle Jun 20 '13 at 17:01
@DavidCarlisle Thank you for your answer. There is something that puzzles me. If the color package uses \AtBeginDocument to set some parameters, then what happens if some other packages also use the \AtBeginDocument in the same way? – Pierre Jun 20 '13 at 20:39
@Pierre It doesn't set "some" parameters it just sets the default color \AtBeginDocument{\let\default@color\current@color} to be the color in force at that point. You made it fail by inserting a box saving command earlier in the begin document hook, which is unfortunate but in 20 years of the color package it's the first time I've seen that happen:) – David Carlisle Jun 20 '13 at 20:44
@DavidCarlisle Thank you David. The solution you provided does indeed work. If I don't use it but I load the class "article" instead of the class "scrartcl" in my little cls file the problem does not occur. So I am not sure as why it fails in the first place. scartcl uses \normalcolor but this should not cause a problem (?). – Pierre Jun 21 '13 at 0:32

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.