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
NEW: TikZ book now 40% off at Amazon.com for a short time.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p
- 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