6

I'd like to define a custom documentclass for assignments which can be optionally passed the minionpro argument to use the Adobe Minion Pro font; if it's not set, the Adobe Utopia font (fourier) shall be used. Now, no matter what I try, pdfLaTeX always spits out the following error:

! LaTeX Error: Missing \begin{document}.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.8 \DeclareOption(mi
                     nionpro){

Here is the mwe.cls:

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{mwe}[2015/12/07 mwe.cls]

\DeclareOption(minionpro){
    % Adobe Minion Pro font for the document, Euler font for math
    \RequirePackage{MinionPro}
    \RequirePackage{eulervm}
}

\DeclareOption(utopia){
    % Adobe Utopia font for the document
    \RequirePackage{fourier}
}

\ExecuteOptions{utopia}
\ProcessOptions\relax
\endinput

And here the mwe.tex

\documentclass{mwe2}
\begin{Document}
content...
\end{Document}

Alternatively, I tried using the etoolbox package to work around the package loading inside of the options, but that gave me the same error. Nevertheless, here the modified mwe.cls:

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{mwe}[2015/12/07 mwe.cls]
\RequirePackage{etoolbox}

\providebool{minionpro}
\setbool{minionpro}{false}

\DeclareOption(minionpro){
    \setbool{minionpro}{true}
}


\ProcessOptions\relax

\ifthenelse{minionpro}{
    % Adobe Minion Pro font for the document, Euler font for math
    \RequirePackage{MinionPro}
    \RequirePackage{eulervm}
}{
    % Adobe Utopia font for the document
    \RequirePackage{fourier}
}

\endinput
3
  • \DeclareOption needs curly {} not round () braces and \ifthenelse is from ifthen not etoolbox. I think it should be something like \ifbool. – Nicola Talbot Dec 7 '15 at 20:21
  • (Of course, the option exists to use the rock-solid expl3 API.) – Sean Allred Dec 7 '15 at 20:31
  • Sorry, the etoolbox/ifthen mixup is due to me copying the MWE together from multiple sources, I've also tried the already-deprecated ifthen package prior to etoolbox. – Big-Blue Dec 7 '15 at 20:38
6

The command \ifthenelse is in the ifthen package. If you want to check whether a boolean bool is true you can use the command \ifthenelse{\boolean{bool}}{}{}. Also I think that you have to declare the boolean values before using the \newboolean command.

Additionally as already pointed out by Nicola Talbot in the comments the \DeclareOption command needs curly brackets {} instead of ().

I think the following version of mwe.cls should work:

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{mwe}[2015/12/07 mwe.cls]

\RequirePackage{ifthen}
\newboolean{minionpro}
\newboolean{utopia}


\DeclareOption{minionpro}{%
    % Adobe Minion Pro font for the document, Euler font for math
    \setboolean{minionpro}{true}}

\DeclareOption{utopia}{%
    % Adobe Utopia font for the document
    \setboolean{utopia}{true}}

\ExecuteOptions{utopia}
\ProcessOptions\relax

\ifthenelse{\boolean{minionpro}}{%
    \RequirePackage{MinionPro}
    \RequirePackage{eulervm}}{}
\ifthenelse{\boolean{utopia}}{%
    \RequirePackage{fourier}}{}

\endinput

EDIT: In the following an alternative version using etoolbox instead of ifthen:

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{mwe}[2015/12/07 mwe.cls]

\RequirePackage{etoolbox}
\newbool{minionpro}
\newbool{utopia}

\DeclareOption{minionpro}{%
    % Adobe Minion Pro font for the document, Euler font for math
    \booltrue{minionpro}}

\DeclareOption{utopia}{%
    % Adobe Utopia font for the document
    \booltrue{utopia}}

\ExecuteOptions{utopia}
\ProcessOptions\relax
\ifbool{minionpro}{%
    \RequirePackage{MinionPro}
    \RequirePackage{eulervm}}{}
\ifbool{utopia}{\RequirePackage{fourier}}{}

\endinput

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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