# Conflict between TikZ and university thesis class file

When compiling a document using my university's thesis class file and the TikZ package I receive an error message (missing number, treated as zero). Would someone know how I can solve this problem?

\documentclass[phd,bottom,nosig]{usbthesis}
\usepackage{tikz}
\begin{document}
Test 1-2-3
\end{document}


The class file can be found here:

-
– yo' Jan 11 '13 at 0:00
Error message goes away if you add \RequirePackage{tikz} before the \documentclass. – Peter Grill Jan 11 '13 at 0:06

In usbthesis.cls change the line:



to,



and use \myyear rather than \year in your document.

It looks like pgfmathfunctions.random.code.tex uses \year to generate a random seed. Since the class redefines \year before it's use in that file, you're getting the error.

-
How did you discover this? – Sigur Jan 11 '13 at 0:12
@sigur TexnicCenter will take you to the line where an error was produced. That opened up the pgfmathfunctions file and showed that the error was produced in the line: \xdef\pgfmath@rnd@z{\the\c@pgfmath@counta}. Since none of that was likely to have been clobbered by the class, I checked the line above, which used \year and that seemed a likely candidate :) – Scott H. Jan 11 '13 at 0:18

The class file badly redefines \year, which is a TeX macro for the current year, and is used by pgf to set a random number seed when it loads.

Changing the order of loading the packages, as Peter Grill suggests, will fix the MWE but other issues may still be present.

In the following, use \setyear instead of \year from the class:

\let\oldyear\year
\documentclass[phd,bottom,nosig]{usbthesis}
\let\setyear\year
\let\year\oldyear
\errorcontextlines=\maxdimen
\usepackage{tikz}
\begin{document}
Test 1-2-3
\end{document}


You should probably also do something similar for \month.

If you are able to tell the University to fix their class file, then Scott H.'s answer is preferable (with a \mymonth as well).

-
@hjms I'll leave my answer up, but this is the better solution since you don't have to muck around with the class file. – Scott H. Jan 11 '13 at 0:27

If you don't want to change the .cls file you could simply add

\RequirePackage{tikz}


before the \documentclass.

## Code:

\RequirePackage{tikz}
\documentclass[phd,bottom,nosig]{usbthesis}
%\usepackage{tikz}% no longer needed.
\begin{document}
Test 1-2-3
\end{document}

-