# Problem with defining a titlepage

I am writing a LaTeX 2e class with two options msc and phd for my department theses/dissertations. In this class, I need to define a titlepage for the first page of the theses/dissertations which contains the university name, the department name, the title, the author name and so on. The code is something like the following:

\documentclass[‎phd‎]{‎book‎}‎
‎\makeatletter‎‎
‎‎\newif\if@‎phdthesis‎
‎\@‎phdthesis‎‎false‎
‎\DeclareOption{phd}{\@‎phdthesis‎‎true}‎
‎\newif\if@‎msc‎thesis‎‎
‎\@‎mscthesis‎‎false‎
‎\DeclareOption{‎msc‎}{\@‎mscthesis‎‎true}‎‎
‎‎‎
‎\def\author‎#1{\gdef\@‎author‎{#1}}‎‎‎‎
‎‎\if@‎mscthesis‎‎
‎\def‎‎\mytitle‎‎{‎‎‎‎‎\begin{titlepage}‎‎‎‎
\begin{center}‎
‎A‎  thesis ‎for the degree ‎of master of science by‎\\‎
‎\@author‎‎
\end{center}‎‎
‎\end‎{titlepage}‎‎‎‎
‎‎‎‎}‎‎
‎\fi‎
‎‎\if@‎phdthesis‎‎
‎\def‎‎‎\my‎title{‎‎‎‎\begin{titlepage}‎‎‎
‎   \begin{center}‎
A ‎Dissertation‎ for the ‎Degree‎‎ of Doctor of ‎Philosophy ‎by\\‎
\@author‎
‎   \end{center}‎‎‎‎
‎\end‎{titlepage}‎‎
‎‎‎‎}‎‎
‎\fi‎
‎\makeato‎ther‎
\begin{document}‎
\author{‎Vahid‎}‎‎‎
‎‎\mytitle‎
‎‎\chapter{Chapter Name}‎
‎bla ‎bla ‎bla‎
‎\newpage‎
‎bla ‎bla ‎bla‎‎
‎\end{document}


But I get an error: Undefined control sequence.l.32 \mytitle. I am wondering if anybody help me solve this problem.

-
There are some funny invisible zero-width (spaces?) unicode characters in your code post. They are displayed as <200e> in Vim and make it uncompilable for me. –  Martin Scharrer Feb 15 '11 at 9:46
@Martin: I'm sorry for that. I'm using Texmaker which has been modified for typesetting Right to left languages for writing my code. –  Vahid Damanafshan Feb 15 '11 at 10:30
Consider the memoir class if your university (like mine) has very odd formatting requirements. Chapter 21 of the memoir documentation is an example of doing a thesis design. You can piece enough together with the titlesec, tocloft, and other related packages, but memoir provides most/all of their functionality in one class. –  Mike Renfro Feb 15 '11 at 12:40
@Mike: Thanks for this information. –  Vahid Damanafshan Feb 15 '11 at 18:04

You get this error, because you define the two versions of \mytitle inside conditionals. Both of them are false in you example, so the macro never gets defined.

You missing an \ProcessOptions which actually handles the given [phd] option, before the first use of the if's:

%...
‎\DeclareOption{‎msc‎}{\@‎mscthesis‎‎true}‎‎
\ProcessOptions

‎\def\author‎#1{\gdef\@‎author‎{#1}}‎‎‎‎
%...


I assume here the code is in a class file. Please also see the clsguide for more information on how to define options.

-
Thanks for your hint. But I cannot exactly understand what you mean. Could you please help me to avoid the error? –  Vahid Damanafshan Feb 15 '11 at 9:38
@Vahid: see the update –  Martin Scharrer Feb 15 '11 at 9:47

use it this way, which use msc as default:

\documentclass[‎phd]{book}
\makeatletter

\newif\if@phdthesis
‎\DeclareOption{‎phd‎}{\@‎phdthesis‎‎true}‎‎
\ProcessOptions
‎‎‎
‎\def‎‎‎\my‎title{‎‎‎‎\begin{titlepage}‎‎‎
‎   \begin{center}‎
‎‎\if@‎phdthesis‎‎
A ‎Dissertation‎ for the ‎Degree‎‎ of Doctor of ‎Philosophy ‎by\par
\else‎
‎A‎  thesis ‎for the degree ‎of master of science by‎\par
\fi
\@author‎
‎   \end{center}‎‎‎‎
‎\end‎{titlepage}‎‎}‎‎
‎
‎\makeato‎ther‎
\begin{document}
\author{‎Vahid‎}‎‎‎
‎‎\mytitle‎
‎‎\chapter{Chapter Name}‎
‎bla ‎bla ‎bla‎
‎\newpage‎
‎bla ‎bla ‎bla‎‎
‎\end{document}

-