Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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%
\LoadClass[DIV14,parskip=full,twocolumns,landscape]{scrartcl}%
\else
\LoadClass[DIV14,parskip=full]{scrartcl}%
\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%
\LoadClass[DIV14,parskip=full,landscape,twocolumn]{scrartcl}%
\else
\LoadClass[DIV14,parskip=full]{scrartcl}%
\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
(typearea)             instead of `landscape', too.

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?

share|improve this question
    
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
add comment

1 Answer

up vote 2 down vote accepted

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}
  \LoadClass[DIV14,parskip=full,twocolumn]{scrartcl}
  \RequirePackage[pass]{geometry} % this ensures the correct paper orientation
\else
  \LoadClass[DIV14,parskip=full]{scrartcl}
\fi

If you comment line 2 in test.tex, you'll get instead a one-column portrait document.

share|improve this answer
    
Hi egreg, thanks. 2columns are now working fine. Can you explain, why geometry is needed in this setting? Using the "package"-version it will work. Further the "true" part should always be used here to be tested... it is an implementation following the cited article. –  Bastian Ebeling Jan 11 '12 at 13:19
1  
@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
    
Sorry @egreg! In my more complicated example, which I derived the minexmpl. from, some other things occur. At the moment it seems, as if hyperref helps - but only in a package. Maybe I post another minexmpl. soon. Thx! –  Bastian Ebeling Jan 11 '12 at 13:37
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.