Document ClassesWriting Classes with conditionals...

Information and discussion about specific document classes and how to create your own document classes.
Post Reply
nima
Posts: 2
Joined: Wed Jan 13, 2010 4:34 am

Writing Classes with conditionals...

Post by nima »

I know this has come up before in various forms, such as those in http://www.latex-community.org/forum/vi ... f=5&t=2060, however I think what I'm facing is either different, or I'm not smart enough to figure it out - which is entirely possible :)

Code: Select all

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\DeclareOption{xray}{
    %....code that requires package color and multicol...
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\ProcessOptions\relax
\LoadClassWithOptions{article}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\RequirePackage{optional}
%...
\IfDeclaredOption{xray}{% A construct such as this is what I'm after
    \RequirePackage{multicol}
    \RequirePackage[usenames,dvipsnames]{color} %. Thanks David Carlisle
}
I can't place

Code: Select all

\RequirePackage 
inside the

Code: Select all

\DeclareOption
obviously.

I've tried optional, comment, and the ifx packages, and have failed to get this working, mainly because they don't seem to compile correctly if I try and use them after the Options section of the LaTeX document.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

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

josephwright
Site Moderator
Posts: 814
Joined: Tue Jul 01, 2008 2:19 pm

Re: Writing Classes with conditionals...

Post by josephwright »

This has been answered on c.t.t. Pleas mention when you cross-post questions in different forums.
Joseph Wright
nima
Posts: 2
Joined: Wed Jan 13, 2010 4:34 am

Re: Writing Classes with conditionals...

Post by nima »

I posted there after here actually - but you make a perfectly valid point. I'll make sure I do that next time. :)
Post Reply