Document Classes ⇒ Passing Option to a new Class
Passing Option to a new Class
I'm writing a new class, based on 12pt article, but with one option which I'll call [large] which will load [17pt]{extarticle}. Thus:
Near the start of my class I have
\LoadClass[12pt]{article}
followed be a load of minor modifications and new definitions.
But if I start my latex file with \documentclass[large]{myclass} I need the class to execute instead
\LoadClass[17pt]{extarticle}
I have The LaTeX Companion in front of me, but I can't figure out how to do this. Any suggestions?
Thanks for any help
James
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Passing Option to a new Class
Thorsten
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Re: Passing Option to a new Class
I want something equivalent to,
if option = large then
\LoadClass[17pt]{extarticle}
else
\LoadClass[12pt]{article}
end if
But I don't see how to do that.
James
Passing Option to a new Class
Code: Select all
\NeedsTeXFormat{LaTeX2e}
\newcommand*\myfontsize{12pt}
\newcommand*\parentclass{article}
\DeclareOption{large}{%
\renewcommand*\myfontsize{17pt}%
\renewcommand*\parentclass{extarticle}%
}
\DeclareOption{standard}{%
\renewcommand*\myfontsize{12pt}%
\renewcommand*\parentclass{article}
}
\ProcessOptions
\LoadClass[\myfontsize]{\parentclass}
\endinput
Nicola Talbot
Creating a Minimal Example: http://www.dickimaw-books.com/latex/minexample/
Re: Passing Option to a new Class
James
ps Indeed, extarticle does allow the 12pt option. However, the 17pt option is only going to be used on rare occasions, so I wanted to avoid using extarticle unless necessary in case some users didn't have it installed.
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Passing Option to a new Class
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10