As already Jon and Alex R. explicitely or implicitely wrote in their comments, this can very well done with conditionals. As I discovered you already load the packages etoolbox and xifthen (which loads in background ifthen). One could also use the pure TeX version. etoolbox provides two different kinds of conditionals, beside TeX Booleans also LaTeX toggles (more see in documentation under “Boolean Flags”). I will try to show here all three/four. Which one you use, is mostly a matter of taste:
First define a Boolean. This must be done very early, at least before the first use of \KOMAoptions, see below. Of course in the case of etoolbox and xifthen the package must be loaded before. Note that for the TeX flags both packages define the pure TeX Boolean in the background, so putting all the following together into one file will produce errors.
% pure TeX
\newif\ifAFive
% (x)ifthen
\newboolean{AFive}
% etoolbox TeX flag
\newbool{AFive}
% etoolbox LaTeX flag
\newtoggle{AFive}
Now change your first line to
\documentclass[DIV15,BCOR12mm]{scrbook}
and somewhere later in the preamble (again: for etoolbox and xifthen after package loading) you add this:
% pure TeX
\ifAFive
\KOMAoptions{paper=a5,twoside=true}
\else
\KOMAoptions{paper=a4,twoside=false}
\fi
% (x)ifthen
\ifthenelse{\boolean{AFive}}{
\KOMAoptions{paper=a5,twoside=true}
}{
\KOMAoptions{paper=a4,twoside=false}
}
% etoolbox TeX flag
\ifbool{AFive}{
\KOMAoptions{paper=a5,twoside=true}
}{
\KOMAoptions{paper=a4,twoside=false}
}
% etoolbox LaTeX flag
\iftoggle{AFive}{
\KOMAoptions{paper=a5,twoside=true}
}{
\KOMAoptions{paper=a4,twoside=false}
}
You can easily add hyperref options here. This package provides a command \hypersetup to change or add options after package loading. Because I suspect you only want to deactivate coloured links for print I suggest you using the option hidelinks. Add this after loading of hyperref, where you probably have a option colorlinks (I only show two versions, the others should be clear from above):
% pure TeX
\ifAFive
\hypersetup{hidelinks=true}
% no \else branch needed in this case
\fi
% (x)ifthen
\ifthenelse{\boolean{AFive}}{
\hypersetup{hidelinks=true}
}{} % the part for Boolean=false is left empty
If you really want to load nohyperref, then simply replace the \hypersetup line. You can merge this with the conditional calls from above, as long as they are placed after all needed packages.
Later on command line for compiling in A4 format you need to change nothing (Booleans and toggles are false, if not explicitely set to true). For A5 format you now compile (with double quotes in Windows, replace them with single quotes in Linux and MacOSX):
when you use the pure flag:
pdflatex "\AFivetrue\input{GeoTopo.tex}"
when you use the (x)ifthen version:
pdflatex "\setboolean{AFive}{true}\input{GeoTopo.tex}"
when you use the etoolbox TeX flag:
pdflatex "\setbool{AFive}{true}\input{GeoTopo.tex}"
when you use the etoolbox LaTeX flag:
pdflatex "\settoggle{AFive}{true}\input{GeoTopo.tex}".
For etoolbox there are also the variants \booltrue{AFive} respective \toggletrue{AFive}.
Edit: I forgot titlepage.tex.
The commands of this short file I would merge into the main file. The \vspace inside of the title definition is wrong I’m sure. You would need an empty line or a \par after it, but (without newly testing) I guess you would get an error in the title. Use the optional argument of the newline command \\[10cm] or, because we want to change this:
Define somewhere in the preamble a new length
\newlength{\timgskip} % from "title image skip"
Then again in conditionals (this time only pure version shown):
\ifAFive
\setlength{\timgskip}{4cm}
\else
\setlength{\timgskip}{10cm}
\fi
This can also merged, as long as it is set after the new length definition.
The according line now must now look like this:
\title{Geometrie und Topologie\\[\timgskip]
\if<something>...\else...\fi) would be the easiest way.etoolboxalso provides lots of advanced options. – jon Jan 23 '14 at 21:34\newif\ifxxx\xxxtrue\ifxxx\def\sth{something}\else\fibefore\documentclass: only if\xxxtrueis not included, will you get an error. (Linebreaks are not provided because of the way comments are formatted.) – jon Jan 23 '14 at 21:42\usepackage{geometry}. I've added a link to the document so you can take a look what I currently have in my preamble. It's pretty big and I thought this is not directly related to my question, so I did not include the document itself. – Martin Thoma Jan 23 '14 at 22:10xifthenonly for one definition of the environmentaufgabe. Try ifetoolbox’s\ifstremptyor, not that strict,\ifblankwork, as well. So you would not need to loadxifthenanymore. – Speravir Jan 24 '14 at 01:28