2

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?

  • 1
    Put the font change inside a group. E.g., \begingroup\fontsize{72}{80}...\@title\endgroup. (Is the ] a typo?) – TH. Jun 19 '17 at 07:50
  • Great it works. ] was a typo. I copied these code from different sources and don't have a good clue what each command within \renewcommand does, for example what does \fontshape{sl} do and which font is \selectfont. could you help me with that? In addition if I want to use the font "Roboto", should I pt in in \fontfamily{}? Thanks in advance. – user136472 Jun 19 '17 at 08:02
  • Just out of curiosity, why do you want to make a class? You can always just input an entire preamble from another file. – John Kormylo Jun 19 '17 at 14:06
  • \selectfont is the thing that actually changes to the font you've selected using the preceding commands like \fontfamily{phv}. You should ask your follow up questions as new questions though. That way more people will see them. – TH. Jun 19 '17 at 15:19

1 Answers1

2

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.

TH.
  • 62,639