18

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

  • Welcome to TeX.SE! – yo' Jan 11 '13 at 0:00
  • 3
    Error message goes away if you add \RequirePackage{tikz} before the \documentclass. – Peter Grill Jan 11 '13 at 0:06
19

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.

  • 1
    How did you discover this? – Sigur Jan 11 '13 at 0:12
  • 5
    @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
14

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
10

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}

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.