I am working on customizing a thesis document class according to my needs.
I am trying to renew the \maketitle
command to modify my title page, and I am facing two problems:
-
I wish to define a newcommand for the logo in the title page. If there is no user-defined parameter, a default value called "logo.pdf" should be passed to the
\includegraphics
command to load the default logo.\newcommand{\logo}[1][logo.pdf]{\includegraphics[width=40mm]{#1}}
Is this correct?
-
There seems to be some problem with my class file, as I keep getting the
Undefined control sequence in \maketitle
error. Below is my document class:
mythesis.cls
:
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{mythesis}[2013/07/25 v1.0 My thesis class]
\LoadClass[a4paper]{report}
\RequirePackage{graphicx} % needed for logo and pictures
\newcommand{\logo}[1][logo.pdf]{\includegraphics[width=40mm]{#1}}
\newcommand{\college}[1][My School]{{#1}}
\newcommand{\degree}[1][My degree]{{#1}}
\newcommand{\university}[1][My university]{{#1}}
\newenvironment{alwayssingle}{%
\@restonecolfalse
\if@twocolumn\@restonecoltrue\onecolumn
\else\if@openright\cleardoublepage\else\clearpage\fi
\fi}%
{\if@restonecol\twocolumn
\else\newpage\thispagestyle{empty}\fi}
\makeatletter
\renewcommand\maketitle{
\begin{alwayssingle}
\begin{center}
{\Huge {\bfseries {\@title}} \par}
{\large \vspace*{10mm} {\@logo \par} \vspace*{15mm}}
{{\Large \bf \@author} \par}
{\large \vspace*{1ex} {{\@college} \par}
{\large \@university \par}
{\Large \it {\@degree} \par}
\vspace*{2ex}
{\today}}
\end{center}
\null\vfill
\end{alwayssingle}
}
\makeatother
thesis.tex
:
\documentclass[12pt]{mythesis}
\begin{document}
\title{My research}
\author{My name}
\logo{logo_new.pdf}
\maketitle
\end{document}
Any help on this is appreciated.
P.S.: I am a newbie, especially in document class creation.
Best Answer
Both your problems are addressed in the below provided edited class file:
Some points:
\makeatletter
and\makeatother
is not required in class and style files. If you give one, then it is not a problem.\@logo
defined above. It will be taken as default if you did not provided\logo
command in your TeX file, otherwise\logo
command will redefine\@logo
with the new file you had given in the TeX file.\@logo
,\@college
,\@degree
,\@university
etc were not defined inside\maketitle
which were causing the error. I have added those in their respective macros.\it
,\bf
,\sl
etc are now obsolete and we need to use\itshape
,\bfseries
,\slshape
etc.Otherwise, its a great way to start with!