[Tex/LaTex] Problem with compilation (color)

colorerrors

I have this code in LaTeX (the .cls file is HERE):

\documentclass[thesis=B,czech]{FITthesis}[2012/06/26]

\usepackage[utf8]{inputenc}

\usepackage{graphicx}

\usepackage{dirtree}

\usepackage{amsmath,amsfonts,amssymb,amsthm}
\usepackage{comment}
\usepackage{longtable}
\usepackage{booktabs,multirow}

\usepackage{tikz}
\usetikzlibrary{shapes.geometric,calc,arrows,decorations.markings,decorations.pathmorphing}

\begin{document}
\begin{center}
\begin{tikzpicture}[scale=2]
    \draw (1,0) -- (0,0) -- (0,1);
\end{tikzpicture}
\end{center}
\end{document}

…and I have an error:

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

How to fix it?

Best Answer

On lines 395-399 of FITthesis.cls one finds:

\AtBeginDocument{
    \if@langczech\frontmatter*\else\frontmatter\fi %cislovani stranek pred prvni kapitolou
    \thispagestyle{empty}
    \if@langczech{Sem vlo{\v z}te zad{\' a}n{\' i} Va{\v s}{\' i} pr{\' a}ce.}\else{Insert here your thesis' task.}\fi

and this reveals the culprit: code used in \AtBeginDocument is still part of the preamble and the class is using the hook to typeset information (in the fourth line in the code I showed above); this, of course, produces an error. The only remedy I see (perhaps there are better options), is to edit the .cls file and to replace the line

\AtBeginDocument{

with the two lines

\RequirePackage{etoolbox}
\AfterEndPreamble{

so the new lines will look like

\RequirePackage{etoolbox}
\AfterEndPreamble{
    \if@langczech\frontmatter*\else\frontmatter\fi %cislovani stranek pred prvni kapitolou
    \thispagestyle{empty}
    \if@langczech{Sem vlo{\v z}te zad{\' a}n{\' i} Va{\v s}{\' i} pr{\' a}ce.}\else{Insert here your thesis' task.}\fi

the description of \AfterEndPreamble from etoolbox:

\AfterEndPreamble{<code>} This hook differs from \AtBeginDocument in that the code is executed at the very end of \begin{document}, after any \AtBeginDocument code.

You should contact the author/maintainer of the class and report this bug.

Related Question