Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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:

http://graduate.physics.sunysb.edu/faq/thesis_template/usbthesis.cls

share|improve this question
    
Welcome to TeX.SE! –  tohecz Jan 11 '13 at 0:00
2  
Error message goes away if you add \RequirePackage{tikz} before the \documentclass. –  Peter Grill Jan 11 '13 at 0:06
add comment

3 Answers 3

up vote 15 down vote accepted

In usbthesis.cls change the line:

\renewcommand{\year}[1]{\newcommand{\@year}{#1}}

to,

\newcommand{\myyear}[1]{\newcommand{\@year}{#1}}

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.

share|improve this answer
    
How did you discover this? –  Sigur Jan 11 '13 at 0:12
4  
@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
add comment

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).

share|improve this answer
    
@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
add comment

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}
share|improve this answer
add comment

Your Answer

 
discard

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.