GeneralSwitch of documentclass/compiler macros

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
JoEgner
Posts: 5
Joined: Thu Jul 22, 2010 10:18 pm

Switch of documentclass/compiler macros

Post by JoEgner »

Hi,

say I have a document I want to compile in three ways:

(1) as \documentclass[param1]{scrbook} with some parameters param1 and possibly some other settings (captions, fonts, etc).

(2) as \documentclass[param2]{scrbook} with some other parameters param2 and possibly some other settings (captions, fonts, etc).

(3) as \documentclass[param3]{scrartcl} with some other parameters param3 and possibly some other settings (captions, fonts, etc).

I could set this up by commenting out/uncommenting the respective commands. This is somewhat tedious and not very elegant. It seems I cannot use packages boolexpr or xifthen, for packages need to be loaded after the documentclass command.

If this were C world, I'd use (evil) macro statements. What's the "right" way to achieve my goal in LaTeX?

Thanks, Jo

Recommended reading 2024:

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

NEW: TikZ book now 40% off at Amazon.com for a short time.

sommerfee
Posts: 503
Joined: Mon Apr 09, 2007 4:20 pm

Re: Switch of documentclass/compiler macros

Post by sommerfee »

You can use both plain TeX (\newif) and LaTeX macros (\newboolean) before \documentclass.
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Switch of documentclass/compiler macros

Post by frabjous »

Another thing to consider would be to create three "wrapper" files which use \input for the same core document.

I.e., make one file like this:

Code: Select all

\documentclass[param1]{scrbook}
\usepackage{font-package-for-this-version}
\newcommand{\something}{Command definition specific to this version.}
...
\input{core.tex}
and another like:

Code: Select all

\documentclass[param2]{scrbook}
\usepackage{some-other-font-package}
\newcommand{\something}{Different definition of same command.}
...
\input{core.tex}
and another however, etc.

Then just have a script or batch file compile all of them.
Post Reply