I know, there is this question but my knowledge regarding .cls files when it comes to latex, is too little. I tried to do as the solution there says there but I don't use begincmd so I don't know how to apply it to my case.

The error message causing the issue:

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

Here the part of .cls file using color:

        pdftitle = {\inserttitle},
        pdfauthor = {\insertauthor},
        pdfsubject = {\insertsubject},
        pdfkeywords = {PI4 Template v1.6},
        citebordercolor = {.36 .93 0},
        linkbordercolor = {1 .6 .33},
        menubordercolor = {1 .6 .33},
        urlbordercolor = {.39 .82 1},
        pdfborder = {0 0 .5}

here the entire .cls file

% Basic class options
\ProvidesClass{pi4-thesis}[2015/12/17 PI4 Thesis Template V1.6]

% Option for language selection.

% Pass otions that are not specified above to the base class.


% Load base class.

% UTF-8 should be supported by all major editors. If this causes problem change it to another
% encoding (e.g., 'latin1').
% ---------------------------------

% Title page details
% ---------------------------------

% Language selection
    \babeltags{lang-main = ngerman}

    \newcommand{\insertcitydate}[2]{#1, den #2}

    \babeltags{lang-main = english}

    \newcommand{\declarationofhonorchap}{\chapter{Declaration of Honour}}
    \newcommand{\insertsupervisordetails}{Supervisor: \insertsupervisor}

    \newcommand{\insertcitydate}[2]{#1, #2}


\babeltags{lang-de = ngerman}
\babeltags{lang-en = english}
% ---------------------------------

% Package includes
% The following list of packages should provide you a more or less complete basis for your thesis.
% However, it might be required that you change some package options or include new ones. For each
% of the used package a very brief description is given. If you like to know more on a specific
% package I recommend that you read the package documentation at http://www.ctan.org/pkg/ (just
% search for the package name). Of course you also can include more packages if you need them.
% Nicer fonts for your document.
% http://www.khirevich.com/latex/microtype/
% Responsible for the style of bibliography and citations.
% Brings color to your document.
% Better formatting of URLs in the text.
% Provides functions for better hyphenation of words.
% Produces clickable links within the PDF file.
% Provides support for including images in your document.
% Support for multiple images in one figure environment.
% More options for tabular envrionments.
% Support for listings (for displaying algorithms, source code, etc.).
% Provides todo notes that help you keep track of what you have to do.
% Produces nonsense text. Can be removed as soon as you started writing your own text.
% Provides the glossary function.
% Some small improvements for the KOMA script packages.
% Allows you to rotate a page correctly in the PDF.
% A more intelligent reference system
% ---------------------------------

% Language options for specific packages
    \renewcommand{\lstlistlistingname}{List of Listings}
% ---------------------------------

% Layout tweaks
% Schusterjungen und Hurenkinder verhindern. Siehe deutsches TeX-FAQ (6.1.3)
\clubpenalty = 10000
\widowpenalty = 10000
\displaywidowpenalty = 10000
% ---------------------------------

% Title page
\title{\textnormal{\textsc{\Large \insertsubject}}\\
% ---------------------------------

% Adaptions for the actual document
    pdftitle = {\inserttitle},
    pdfauthor = {\insertauthor},
    pdfsubject = {\insertsubject},
    pdfkeywords = {PI4 Template v1.6},
    citebordercolor = {.36 .93 0},
    linkbordercolor = {1 .6 .33},
    menubordercolor = {1 .6 .33},
    urlbordercolor = {.39 .82 1},
    pdfborder = {0 0 .5}


% ---------------------------------

and the main.tex:

% Choose between bachelor thesis or master thesis.
\piivsubject{stuff \texorpdfstring{\\
more \\
% The title of your work.
% Your name.
% Name of your supervisor.
\piivsupervisor{Dr. X}
% The date you submit your thesis. You can substitute the command with any date.

% If you want to use the glossary make sure your 'makeindex' toolchain is working correctly.
% Alternetively, you might want to look into the 'xindy' option of the glossaries package.


% ---------------------------------
% Begin of abstract
% \blindtext creates a paragraph of non-sense text. Replace it with your actual content.
% End of abstract
% ---------------------------------

% ---------------------------------
% Begin of listings
\microtypesetup{protrusion=false} % disables protrusion locally in the document
% If you should not have any figures, tables or acronyms in your paper remove the according list.
% Uncomment the next line if you use listings in your document.
% \lstlistoflistings
\microtypesetup{protrusion=true} % enables protrusion

% End of listings
% ---------------------------------

% ---------------------------------
% Begin of main part




% End of main part
% ---------------------------------

% ---------------------------------
% Begin of appendix
% Appendix chapters are optional. Use it if you have very long tables or additional figures that
% do not belong to the main text.

% Remove this from the final document



% Fix for long URLs in bibliography
% End of appendix
% ---------------------------------

  • we can not run this example it is far from minimal and inputs multiple files you have not supplied, and you have not shown the original formatting of the error message so it is hard to tell which command is undefined (presumably \current@color} please make a small but complete example that shows the problem. Commented Dec 20, 2020 at 16:53
  • 1
    Thanks for pointing it out! Now it should work.
    – topkek
    Commented Dec 20, 2020 at 17:59
  • 5
    I have the same problem. The minimal example is \documentclass{dinbrief} \usepackage{tikz} \begin{document} hello world! \end{document} with LuaHBTeX, Version 1.12.0 on current Debian Bullseye
    – hpod
    Commented Dec 25, 2020 at 11:01

1 Answer 1


Your class is trying to typeset the title in \AtBeginDocument. This is not a good idea.

If you have a current latex (with a format 2020-10-01) you can declare a rule to move the code to another place:


This isn't perfect either, but at least the color is now correctly setup.

  • This didn't work for me so I had to use this. Commented May 14 at 8:22

You must log in to answer this question.

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