# own class with twocolumns activated in \ifdefined for KOMA and xelatex

I want to do something like in http://stackoverflow.com/questions/1465665/passing-command-line-arguments-to-latex-document.
For better explanation I'll show a minimal running example:
My test.cls:

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{test}[2012/01/11 helper class]
\ifdefined\bastitwocolumns%
\else
\fi


and now my test.tex:

\listfiles
\def\bastitwocolumns{}
\documentclass{test}
%\ifdefined\bastitwocolumns\documentclass[DIV14,parskip=full,landscape,twocolumn]    {scrartcl}\else\documentclass[DIV14,parskip=full]{scrartcl}\fi
\usepackage{polyglossia}\setdefaultlanguage[spelling=new,babelshorthands=true]{german}
\usepackage{blindtext}
\begin{document}
\blindtext\blindtext\blindtext\\
\blindtext
\par
\blindtext\blindtext\blindtext\\
\blindtext
\end{document}


Compiling with xelatex first the way the files are, results in a one column document a4. Activating line 4 and commenting out line 3 results in a two column (so sad portrait) a4 document. The orientation problem might be ignored.
Can anyone explain, why I can not enable this two column setting in my class?

Okay, here is another minimal running example, which shows the problems more precise:

XeLaTeX-file:

\listfiles
\def\bastitwocolumns{}
\documentclass{ebelinguebung}
%\ifdefined\bastitwocolumns\documentclass[DIV14,parskip=full,landscape,twocolumn]    {scrartcl}\else\documentclass[DIV14,parskip=full]    {scrartcl}\fi\usepackage{beamerarticle}\usepackage{oldebelinguebung}
\usepackage{blindtext}
\begin{document}
\blindtext\\ \blindtext \par \blindtext
\end{document}


Class-file:

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{ebelinguebung}[2012/01/11 helper class]
\ifdefined\bastitwocolumns%
\else
\fi
\RequirePackage{beamerarticle}
\RequirePackage[l2tabu,orthodox]{nag}
\RequirePackage{polyglossia}\setdefaultlanguage[spelling=new,babelshorthands=true]    {german}
\RequirePackage{hyperref}


Style-file:

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{ebelinguebung}[2012/01/11]
\RequirePackage[l2tabu,orthodox]{nag}
\RequirePackage{polyglossia}\setdefaultlanguage[spelling=new,babelshorthands=true]{german}
\RequirePackage{hyperref}


And now switching active lines 3 or 4 I get different results (one portrait, one landscape), which I like to understand.

Okay, after many tries I found one solution - which I do not really understand - but by the way:
In the logfile for twocolumn compilation with my class typearea shows (of course) the portrait sizes for the paper. But in the logfile for the package solution, typearea also tells

Package typearea Info: You've used standard option landscape'.
(typearea)             This is correct!
(typearea)             Internally I'm using paper=landscape'.
(typearea)             If you'd like to set the option with \KOMAoptions,
(typearea)             you'd have to use paper=landscape' there


First trying paper=landscape direct into the class options only removes those hint. Second trying to set \KOMAoptions{paper=landscape,twocolumn}% (and removing the class options) within the if clause did, what I wanted.
Can anyone explain that?

-
If you add the commands I suggested, then the document is indeed printed in two column landscape format. –  egreg Jan 12 '12 at 13:46
@egreg yes, you are right of course. But with my solution we do not need a further package loading... Thus, I prefer this a little bit. –  Bastian Ebeling Jan 13 '12 at 10:46

When test.cls is loaded, it follows the "true" part of the conditional, because line 2 of your document defines \bastitwocolumns, but of course it ignores the twocolumns option, because the right name is twocolumn.

Indeed, changing twocolumns into twocolumn in test.cls produces a two column document.

In order to get landscape format, you can modify test.cls in this way:

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{test}[2012/01/11 helper class]
\ifdefined\bastitwocolumns
\PassOptionsToPackage{landscape}{typearea}

If you comment line 2 in test.tex, you'll get instead a one-column portrait document.
@BastianEbeling I tried without it, but didn't succeed in persuading scrartcl to produce a landscape document. I know that geometry issues the right commands in order to have the correct paper format; the pass option will avoid any modification of the parameters. –  egreg Jan 11 '12 at 13:28