Hi
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
Document Classes ⇒ Passing Option to a new Class
Passing Option to a new Class
Last edited by jamesm on Tue Apr 05, 2011 1:47 pm, edited 1 time in total.
NEW: TikZ book now 40% off at Amazon.com for a short time.
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Passing Option to a new Class
I suggest to take a look at the document "LaTeX2e for Class and Package Writers", also know as the »Class Guide«.
Thorsten
Thorsten
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Re: Passing Option to a new Class
I had a look at the class guide but it doesn't seem to solve my problem. I can't see anywhere how to choose between two different document classes.
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
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
Something like the following should work (although I think extarticle also allows 12pt as an option):
Regards
Nicola Talbot
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
LaTeX Resources: http://www.dickimaw-books.com/latexresources.html
Creating a Minimal Example: http://www.dickimaw-books.com/latex/minexample/
Creating a Minimal Example: http://www.dickimaw-books.com/latex/minexample/
Re: Passing Option to a new Class
Brilliant! Thanks Nicola.
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.
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
Then please mark the topic (not only the last post) accordingly as written in Section 3 of the Board Rules (to be read before posting) and as you already have been asked for.
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10