2

In my custom LaTeX class, I've created some different options, such as different font sizes, 11pt, 12pt and 13pt, and paper sizes, such as a4paper and letterpaper. However, only one option from each group should be given, like the following.

\documentclass[12pt, letterpaper]{class} % or
\documentclass[13pt, a4paper]{class} % but never
\documentclass[12pt, 13pt]{class}

The last one shouldn't be used since it specifies the font size twice, which would create an undesirable effect. What I would want instead is that if two or more commands which clash are provided, such as in \documentclass[12pt, 13pt]{class}, my class delivers an error message using \ClassError. How would this be done?

Just in case I would need to use conditional 'if' statements, please try to give code using the style of statement used for the etoolbox package, it's what I use and find easiest.

1 Answer 1

4

Building on my previous answer, here is a way:

\ProvidesClass{akuritsu}

\newif\ifaku@sizegiven
\DeclareOption{12pt}{\def\aku@ptsize{2}\aku@sizegiventrue}
\DeclareOption{11pt}{\def\aku@ptsize{1}\aku@sizegiventrue}
\DeclareOption{10pt}{\def\aku@ptsize{0}\aku@sizegiventrue}
\DeclareOption{12pt-standard}{\def\aku@ptsize{2}}

\ExecuteOptions{12pt-standard}
\ProcessOptions\relax
\PassOptionsToClass{1\aku@ptsize pt}{article}

\LoadClass{article}

\ifaku@sizegiven
  \ClassError{akuritsu}
     {Multiple font size options}
     {You have specified two or more options among `10pt', `11pt' or `12pt'}
\fi

You have to use a different default option, as otherwise the error message would be issued for a single font size option.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .