[Tex/LaTex] How to change font and font size of title in a class file

document-classesfontsize

I'm newbie in making LaTeX classes and this is my first attempt. I'm trying to create a class where I select the font type (Roboto) and its size for different sections of the file. I've tried the following:

    \NeedsTeXFormat{LaTeX2e}
    \ProvidesClass{idletechs}[some text]

    \newcommand{\headlinecolor}{\normalcolor}

    \DeclareOption*{\PassOptionsToClass{\CurrentOption}{report}}
    \ProcessOptions\relax

    \LoadClass[12pt]{report}

    \renewcommand{\maketitle}{ \fontsize{72}{80}\fontfamily{phv}\fontseries{b}%
    \fontshape{sl}\selectfont\headlinecolor
    \@title ]
    }

However, this applies the font size on the whole document and not just on the title. Could anyone give me some hints?

Best Answer

Here's a complete example using the article class.

\documentclass{article}
\newcommand\headlinecolor{\normalcolor}

\makeatletter
\renewcommand*\maketitle{%
    \begingroup
    \centering
    \fontsize{72}{80}% 72pt on 80pt leading
    \fontfamily{phv}% Helvetica
    \fontseries{b}% Bold
    \fontshape{sl}% Slanted
    \selectfont
    \headlinecolor
    \@title
    \par
    \vskip1in
    \endgroup
}
\makeatother

\title{Foo Bar}

\begin{document}
\maketitle

Some other text.
\end{document}

enter image description here

If you want the Roboto font instead, then the easiest way is to \usepackage{roboto} (or \RequirePackage{roboto} inside a class definition) and just use standard font commands.

\documentclass{article}
\usepackage{roboto}
\newcommand\headlinecolor{\normalcolor}

\makeatletter
\renewcommand*\maketitle{%
    \begingroup
    \centering
    \fontsize{72}{80}% 72pt on 80pt leading
    \roboto % Roboto
    \bfseries % Bold
    \slshape % Slanted
    \headlinecolor
    \@title
    \par
    \vskip1in
    \endgroup
}
\makeatother

\title{Foo Bar}

\begin{document}
\maketitle

Some other text.
\end{document}

enter image description here

I really wouldn't do it this way. See this question for some suggestions.