From 524b07990fd2040ab6ce24b015b9a2bd4544a3c1 Mon Sep 17 00:00:00 2001
From: Karl Berry <karl@freefriends.org>
Date: Sun, 20 Aug 2006 00:02:10 +0000
Subject: koma-script 2.95b, using provided texmf zip

git-svn-id: svn://tug.org/texlive/trunk@1990 c570f23f-e606-0410-a88d-b1316a301751
---
 .../texmf-dist/tex/latex/koma-script/typearea.sty  | 1306 +++++++++++---------
 1 file changed, 753 insertions(+), 553 deletions(-)

(limited to 'Master/texmf-dist/tex/latex/koma-script/typearea.sty')

diff --git a/Master/texmf-dist/tex/latex/koma-script/typearea.sty b/Master/texmf-dist/tex/latex/koma-script/typearea.sty
index dcd3046bed2..72c50031e09 100644
--- a/Master/texmf-dist/tex/latex/koma-script/typearea.sty
+++ b/Master/texmf-dist/tex/latex/koma-script/typearea.sty
@@ -4,633 +4,833 @@
 %%
 %% The original source files were:
 %%
-%% scrclass.dtx  (with options: `package,typearea')
-%% scrlogo.dtx 
+%% scrkvers.dtx  (with options: `package,typearea')
+%% scrktare.dtx  (with options: `package,identify')
+%% scrkbase.dtx  (with options: `load')
+%% scrktare.dtx  (with options: `package,option,body')
+%% scrlogo.dtx  (with options: `logo')
 %% 
-%% Copyright (C) 1994-2004 Markus Kohm and Frank Neukam.
+%% Copyright (c) 1994-2006
+%% Markus Kohm and any individual authors listed elsewhere in this file.
 %% 
-%% All rights reserved. For further copyright information see the file
-%% LEGAL.TXT or LEGALDE.TXT.
+%% This file was generated from file(s) of the KOMA-Script bundle.
+%% ---------------------------------------------------------------
 %% 
-%% This file is part of the LaTeX2e KOMA-Script bundle.
-%% ----------------------------------------------------
+%% It may be distributed under the conditions of the
+%% LaTeX Project Public License in the version distributed together
+%% with KOMA-Script, see file `lppl.txt' or `lppl-de.txt'.
 %% 
-%% The KOMA-Script bundle bases on the Script-family created by
-%% Frank Neukam 1993 and the standard documents classes created
-%% by the LaTeX3-Team 1994-1996.
-%% ------------------------------------------------------------------------
+%% This file may only be distributed together with a copy of the
+%% KOMA-Script bundle.  You may however distribute the
+%% KOMA-Script bundle without all such generated files.  See also
+%% `lppl.txt' or `lppl-de.txt' for additional information.
 %% 
-%%  This system is distributed in the hope that it will be useful,
-%%  but WITHOUT ANY WARRANTY; without even the implied warranty of
-%%  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+%% The list of files belonging to KOMA-Script distribution is given in
+%% the file `manifest.txt'.  See also `lppl.txt' or `lppl-de.txt' for
+%% additional information.
 %% 
+%% If this file is a beta version, you are not allowed to distribute it.
 %% 
-%% IMPORTANT NOTICE:
+%% English and German manuals are part of KOMA-Script bundle.
+%% ----------------------------------------------------------
 %% 
-%% For error reports in case of UNCHANGED versions see documentation.
+%% See `README'.
 %% 
-%% Please do not request updates from us directly. Distribution is
-%% done through Mail-Servers, Mailboxes and TeX organizations.
+%% The KOMA-Script bundle (but maybe not this file) was based upon the
+%% LaTeX2.09 Script family created by Frank Neukam 1993 and the LaTeX2e
+%% standard classes created by The LaTeX3 Project 1994-1996.
 %% 
-%% You are not allowed to change this file.
-%% 
-%% You are allowed to distribute this file under the condition that
-%% it is distributed together with all files mentioned in readme.txt
-%% and liesmich.txt. See LEGAL.TXT or LEGALDE.TXT for further
-%% information.
-%% 
-%% If you receive only some of these files from someone, complain!
-%% 
-%% You are NOT ALLOWED to distribute this file alone.
-%% 
-\NeedsTeXFormat{LaTeX2e}[1995/12/01]
-\ProvidesPackage{%
-  typearea%
-  }
-  [2004/09/16 v2.9t LaTeX2e KOMA
-    package]
-\typeout{Package typearea, \csname ver@typearea.sty\endcsname%
-  ^^J\@spaces\@spaces\@spaces\@spaces\space\space
-  Copyright (C) Frank Neukam, 1992-1994%
-  ^^J\@spaces\@spaces\@spaces\@spaces\space\space
-  Copyright (C) Markus Kohm, 1994-2002^^J}
+%%% From File: scrkvers.dtx
+\begingroup
+  \makeatletter
+  \ifx\KOMAScriptVersion\undefined
+    \newcommand*{\@CheckKOMAScriptVersion}[1]{%
+      \gdef\KOMAScriptVersion{#1}%
+    }%
+  \else
+    \newcommand*{\@CheckKOMAScriptVersion}[1]{%
+      \def\@tempa{#1}%
+      \ifx\KOMAScriptVersion\@tempa\else
+        \@latex@warning@no@line{%
+          \noexpand\KOMAScriptVersion\space is
+          `\KOMAScriptVersion',\MessageBreak
+          but `#1' was expected!\MessageBreak
+          You should not use classes, packages or files
+          from\MessageBreak
+          different KOMA-Script versions%
+        }%
+      \fi
+    }
+  \fi
+  \@CheckKOMAScriptVersion{2006/07/30 v2.95b KOMA-Script}%
+\endgroup
+%%% From File: scrktare.dtx
+\ProvidesPackage{typearea}[%
+  \KOMAScriptVersion\space package (type area)]
+\typeout{%
+  Package typearea, \csname ver@typearea.sty\endcsname^^J%
+  \@spaces\@spaces\@spaces\@spaces\space\space
+  Copyright (C) Frank Neukam, 1992-1994^^J%
+  \@spaces\@spaces\@spaces\@spaces\space\space
+  Copyright (C) Markus Kohm, 1994-2002^^J%
+}
+%%% From File: scrkbase.dtx
+\RequirePackage{scrkbase}[\KOMAScriptVersion]
+%%% From File: scrktare.dtx
 \newcommand*\SetDIVList[1]{\def\ta@divlist{{}{}{}{}{}{}{}{}{}#1}}
 \newcommand*\SetXDIVList[1]{\def\ta@divlist{#1}}
 \newlength{\ta@bcor}
-\providecommand\ifnumber[3]{
- \begingroup\@tempswafalse\let\scr@next\test@number
- \expandafter\scr@next#1\scr@next
- \if@tempswa\endgroup#2\else\endgroup#3\fi
-}
-\newcommand*{\test@number}[1]{
- \ifx \scr@next#1
-  \let\scr@next\relax
- \else
-  \@tempcnta=\expandafter\expandafter\expandafter\number
-  \expandafter`#1\relax
-  \ifnum \@tempcnta>47\relax
-   \ifnum \@tempcnta<58\relax
-    \@tempswatrue
-   \else\@tempswafalse\fi
-  \else\@tempswafalse\fi
-  \if@tempswa\else\let\scr@next\gobble@till@next\fi\fi
- \scr@next}
-\newcommand*{\gobble@till@next}{}
-\def\gobble@till@next#1\scr@next{}
-\newcommand{\ifdimen}[3]{
- \begingroup\@tempswatrue\let\scr@next\test@posdimen
- \expandafter\test@dimen#1\scr@next
- \if@tempswa\endgroup#2\else\endgroup#3\fi
-}
-\newcommand*{\test@dimen}[1]{\ifx -#1\else\ifx +#1\else
-   \def\scr@next{\let\scr@next\test@posdimen\scr@next#1}\fi\fi\scr@next}
-\newcommand*{\test@posdimen}[1]{
- \ifx \scr@next#1
-  \@tempswafalse\let\scr@next\relax
- \else
-  \if .#1\else\if ,#1\else
-    \@tempcnta=%
-     \expandafter\expandafter\expandafter\number\expandafter`#1\relax
-    \ifnum \@tempcnta>47\relax
-     \ifnum \@tempcnta<58\relax
-     \else\def\scr@next{\test@dimunt#1}\fi
-    \else\def\scr@next{\test@dimunt#1}\fi\fi\fi\fi
- \scr@next}
-\newcommand*{\test@dimunt}{}
-\def\test@dimunt#1\scr@next{%
-  \expandafter\test@trueunt#1truetrue\test@trueunt}
-\newcommand*{\test@trueunt}{}
-\def\test@trueunt#1true#2true#3\test@trueunt{
- \edef\@tempa{#1}
- \ifx\@tempa\@empty\test@@ifdimunt{#2}\else\test@@ifdimunt{#1}\fi}
-\newcommand*\test@@ifdimunt[1]{
- \@tempswafalse
- \ifstr{#1}{pt}{\@tempswatrue}{}
- \ifstr{#1}{pc}{\@tempswatrue}{}
- \ifstr{#1}{in}{\@tempswatrue}{}
- \ifstr{#1}{bp}{\@tempswatrue}{}
- \ifstr{#1}{cm}{\@tempswatrue}{}
- \ifstr{#1}{mm}{\@tempswatrue}{}
- \ifstr{#1}{dd}{\@tempswatrue}{}
- \ifstr{#1}{cc}{\@tempswatrue}{}
- \ifstr{#1}{sp}{\@tempswatrue}{}}
-\newcommand\ifstr[4]{
- \begingroup\edef\@tempa{#1}\edef\@tempb{#2}
- \ifx\@tempa\@tempb\endgroup#3\else\endgroup#4\fi}
+\newcount\ta@div
 \newcommand*{\@BCOR}{\expandafter\@@BCOR\CurrentOption BCORBCOR\@@BCOR}
 \newcommand*{\@@BCOR}{}
-\def\@@BCOR #1BCOR#2BCOR#3\@@BCOR{
- \edef\@tempa{#1}\ifx\@tempa\@empty
-  \edef\@tempa{#3}\def\@tempb{BCOR}\ifx\@tempa\@tempb
-   \ifdimen{#2}{\setlength{\ta@bcor}{#2}}{\ta@opt@err}
-  \else\ta@opt@err\fi
- \else\ta@opt@err\fi}
-\newcount\ta@div
+\def\@@BCOR #1BCOR#2BCOR#3\@@BCOR{%
+  \ifstr{#1}{}{%
+    \ifstr{#3}{BCOR}{%
+      \ifdimen{#2}{\setlength{\ta@bcor}{#2}}{\scr@pti@nerr@r}%
+    }{\scr@pti@nerr@r}%
+  }{\scr@pti@nerr@r}%
+}
 \newcommand*{\@DIV}{\expandafter\@@DIV\CurrentOption DIVDIV\@@DIV}
 \newcommand*{\@@DIV}{}
-\def\@@DIV #1DIV#2DIV#3\@@DIV{
- \edef\@tempa{#1}\ifx\@tempa\@empty
-  \edef\@tempa{#3}\def\@tempb{DIV}\ifx\@tempa\@tempb
-   \ifnumber{#2}{\ta@div=#2\relax}{\ta@opt@err}
-  \else\ta@opt@err\fi
- \else\@BCOR\fi}
+\def\@@DIV #1DIV#2DIV#3\@@DIV{%
+  \edef\@tempa{#1}\ifx\@tempa\@empty
+    \edef\@tempa{#3}\def\@tempb{DIV}\ifx\@tempa\@tempb
+      \ifnumber{#2}{\ta@div=#2\relax}{\scr@pti@nerr@r}%
+    \else\scr@pti@nerr@r\fi
+  \else\@BCOR\fi
+}
 \newcommand{\@headlines}{%
-  \expandafter\@@headlines\CurrentOption headlines\@@headlines}
+  \expandafter\@@headlines\CurrentOption headlines\@@headlines%
+}
 \newcommand*{\@@headlines}{}
 \def\@@headlines #1headlines#2\@@headlines{
   \edef\@tempa{#2}\edef\@tempb{headlines}\ifx\@tempa\@tempb
-    \setlength{\@tempdima}{#1\baselineskip}
-    \def\ta@hh{#1\baselineskip}
-  \else\@DIV\fi}
+    \setlength{\@tempdima}{#1\baselineskip}%
+    \def\ta@hh{#1\baselineskip}%
+  \else\@DIV\fi
+}
 \newcommand\isopaper[2][a]{%
- \ifx a#1
-  \setlength{\paperwidth}{841sp}\setlength{\paperheight}{1189sp}
- \else\ifx b#1
-  \setlength{\paperwidth}{1000sp}\setlength{\paperheight}{1414sp}
- \else\ifx c#1
-  \setlength{\paperwidth}{917sp}\setlength{\paperheight}{1297sp}
- \else\ifx d#1
-  \setlength{\paperwidth}{771sp}\setlength{\paperheight}{1090sp}
- \else
-  \PackageError{typearea}
-   {Unknown ISO/DIN-papersize-letter #1}
-   {There are only four defined paperscalings:\MessageBreak
-    a = ISO/DIN-A, b = ISO/DIN-B, c = ISO/DIN-C, d = ISO/DIN-D\MessageBreak
-    Read KOMA-Script-documentation for further information.}
-  \setlength{\paperwidth}{841sp}\setlength{\paperheight}{1189sp}
- \fi\fi\fi\fi
- \@tempcnta=#2\relax
- \@whilenum\@tempcnta>0
+  \ifx a#1
+    \setlength{\paperwidth}{841sp}%
+    \setlength{\paperheight}{1189sp}%
+  \else\ifx A#1
+      \setlength{\paperwidth}{841sp}%
+      \setlength{\paperheight}{1189sp}%
+    \else\ifx b#1
+        \setlength{\paperwidth}{1000sp}%
+        \setlength{\paperheight}{1414sp}%
+      \else\ifx B#1
+          \setlength{\paperwidth}{1000sp}%
+          \setlength{\paperheight}{1414sp}%
+        \else\ifx c#1
+            \setlength{\paperwidth}{917sp}%
+            \setlength{\paperheight}{1297sp}%
+          \else\ifx C#1
+              \setlength{\paperwidth}{917sp}%
+              \setlength{\paperheight}{1297sp}%
+            \else\ifx d#1
+                \setlength{\paperwidth}{771sp}%
+                \setlength{\paperheight}{1090sp}%
+              \else\ifx D#1
+                  \setlength{\paperwidth}{771sp}%
+                  \setlength{\paperheight}{1090sp}%
+                \else
+                  \PackageError{typearea}{%
+                    Unknown ISO/DIN-papersize-letter #1%
+                  }{%
+                    There are only four defined paper scalings:\MessageBreak
+                    a = ISO/DIN-A, b = ISO/DIN-B, c = ISO/DIN-C,
+                    d = ISO/DIN-D\MessageBreak
+                    Read KOMA-Script-documentation for further information.%
+                  }%
+                  \setlength{\paperwidth}{841sp}%
+                  \setlength{\paperheight}{1189sp}%
+                \fi
+              \fi
+            \fi
+          \fi
+        \fi
+      \fi
+    \fi
+  \fi
+  \@tempcnta=#2\relax
+  \@whilenum\@tempcnta>0
   \do{\setlength{\@tempdima}{\paperwidth}
-      \setlength{\paperwidth}{.5\paperheight}
-      \setlength{\paperheight}{\@tempdima}
-      \advance\@tempcnta by\m@ne}
- \multiply\paperwidth by186468\relax
- \multiply\paperheight by186468\relax}
-\newcommand*{\x@paper}{\expandafter\x@@paper\CurrentOption paper\x@@paper}
+    \setlength{\paperwidth}{.5\paperheight}
+    \setlength{\paperheight}{\@tempdima}
+    \advance\@tempcnta by\m@ne
+  }
+  \multiply\paperwidth by186468
+  \multiply\paperheight by186468
+}
+\newcommand*{\iso@paper}[1]{\expandafter\iso@@paper#1\@nil}
+\newcommand*{\iso@@paper}{}
+\def\iso@@paper#1#2\@nil{%
+  \@tempswafalse
+  \if #1a\@tempswatrue
+  \else\if #1A\@tempswatrue
+    \else\if #1b\@tempswatrue
+      \else\if #1B\@tempswatrue
+        \else\if #1c\@tempswatrue
+          \else\if #1C\@tempswatrue
+            \else\if #1d\@tempswatrue
+              \else\if #1D\@tempswatrue
+  \fi\fi\fi\fi\fi\fi\fi\fi
+  \if@tempswa
+    \ifnumber{#2}{\isopaper[#1]{#2}}{\@tempswafalse}%
+  \fi
+}
+\newcommand*{\x@paper}{%
+  \expandafter\x@@paper\CurrentOption paper\x@@paper%
+}
 \newcommand*{\x@@paper}{}
-\def\x@@paper #1#2paper#3\x@@paper{
- \edef\@tempa{paper}\edef\@tempb{#3}\ifx\@tempa\@tempb
-  \ifnumber{#2}{
-   \ifx a#1\isopaper[a]{#2}
-   \else\ifx b#1\isopaper[b]{#2}
-   \else\ifx c#1\isopaper[c]{#2}
-   \else\ifx d#1\isopaper[d]{#2}
-   \else\ta@opt@err\fi\fi\fi\fi
-  }{\ta@opt@err}
- \else\@headlines\fi}
-\newcommand*{\ta@opt@err}{
- \PackageError{typearea}
-              {Unknown option \CurrentOption}
-              {You've used an unknown option.\MessageBreak
-              Read the KOMA-Script-documentation for further
-              information.}}
-\newif\if@hincl
-\DeclareOption{headinclude}{\@hincltrue}
-\DeclareOption{headexclude}{\@hinclfalse}
-\newif\if@fincl
-\DeclareOption{footinclude}{\@fincltrue}
-\DeclareOption{footexclude}{\@finclfalse}
-\@ifundefined{mincltrue}{\newif\if@mincl}{}
-\DeclareOption{mpinclude}{\@mincltrue}
-\DeclareOption{mpexclude}{\@minclfalse}
-\DeclareOption{dvips}{\AtBeginDocument{\AtBeginDvi{%
-      \special{papersize=\the\paperwidth,\the\paperheight}}}}
-\DeclareOption{pdftex}{\AtBeginDocument{%
-    \pdfpagewidth=\paperwidth \pdfpageheight=\paperheight}}
-\newcommand{\scr@ifpdfoutput}[2]{%
-  \begingroup\@ifundefined{pdfoutput}{\endgroup #2}{\endgroup%
-    \ifnum\pdfoutput>0\relax #1\else #2\fi}}%
-\@ifundefined{ifpdfoutput}{%
-  \let\ifpdfoutput\scr@ifpdfoutput%
+\def\x@@paper #1#2paper#3\x@@paper{%
+  \ifstr{#3}{paper}{%
+    \ifnumber{#2}{%
+      \ifstr{#1}{a}{%
+        \isopaper[a]{#2}%
+      }{%
+        \ifstr{#1}{b}{%
+          \isopaper[b]{#2}%
+        }{%
+          \ifstr{#1}{c}{%
+            \isopaper[c]{#2}%
+          }{%
+            \ifstr{#1}{d}{%
+              \isopaper[d]{#2}%
+            }{\scr@pti@nerr@r}%
+          }%
+        }%
+      }%
+    }{\scr@pti@nerr@r}%
   }{%
-  \PackageInfo{typearea}{%
-    \string\ifpdfoutput\space already defined.\MessageBreak
-    If \string\ifpdfoutput\space does not behave like\MessageBreak
-    is is described at the KOMA-Script manual, try to\MessageBreak
-    load `typearea.sty' earlier or find out at which\MessageBreak
-    package or class \string\ifpdfoutput\space was defined.}}
-\DeclareOption{pagesize}{\AtBeginDocument{%
-    \scr@ifpdfoutput
-    {\pdfpagewidth=\paperwidth\pdfpageheight=\paperheight}
-    {\AtBeginDvi{\special{papersize=\the\paperwidth,\the\paperheight}}}}}
-\DeclareOption{a4paper}{\isopaper{4}}
-\DeclareOption{a5paper}{\isopaper{5}}
-\DeclareOption{letterpaper}
-   {\setlength\paperheight {11in}%
-    \setlength\paperwidth  {8.5in}}
-\DeclareOption{legalpaper}
-   {\setlength\paperheight {14in}%
-    \setlength\paperwidth  {8.5in}}
-\DeclareOption{executivepaper}
-   {\setlength\paperheight {10.5in}%
-    \setlength\paperwidth  {7.25in}}
+    \@headlines
+  }%
+}
+\newcommand*{\scr@pti@nerr@r}{
+  \@unknownoptionerror
+}
+\KOMA@key{headlines}{%
+  \begingroup
+    \setlength{\@tempdima}{#1\baselineskip}%
+  \endgroup
+  \def\ta@hh{#1\baselineskip}%
+}
+\KOMA@ifkey{headinclude}{@hincl}
+\KOMA@DeclareObsoleteOption[\PackageInfo]{headexclude}{%
+  headinclude=false%
+}
+\KOMA@ifkey{footinclude}{@fincl}
+\KOMA@DeclareObsoleteOption[\PackageInfo]{footexclude}{%
+  footinclude=false%
+}
+\KOMA@ifkey{mpinclude}{@mincl}
+\KOMA@DeclareObsoleteOption[\PackageInfo]{mpexclude}{%
+  mpinclude=false%
+}
+\KOMA@key{BCOR}{%
+  \edef\@tempa{#1}\edef\@tempb{current}\ifx\@tempa\@tempb\else
+    \setlength{\ta@bcor}{#1}%
+  \fi
+}
+\AtEndOfPackage{\KOMA@key{BCOR}{\typearea[{#1}]{last}}}
+\KOMA@key{DIV}[calc]{%
+  \edef\@tempa{#1}%
+  \def\@tempb{last}\ifx\@tempa\@tempb\let\@tempa=\@lastdiv\fi
+  \def\@tempb{current}\ifx\@tempa\@tempb\else
+    \def\@tempb{default}\ifx\@tempa\@tempb\ta@div=0 \else
+      \def\@tempb{calc}\ifx\@tempa\@tempb\ta@div=2 \else
+        \def\@tempb{classic}\ifx\@tempa\@tempb\ta@div=3 \else
+          \ta@div=\@tempa
+        \fi
+      \fi
+    \fi
+  \fi
+}
+\AtEndOfPackage{\KOMA@key{DIV}{\typearea[current]{#1}}}
+\KOMA@DeclareObsoleteOption[\PackageInfo]{DIVcalc}{DIV=calc}
+\KOMA@DeclareObsoleteOption[\PackageInfo]{DIVclassic}{DIV=classic}
+\KOMA@key{twocolumn}[true]{%
+  \KOMA@set@ifkey{twocolumn}{@twocolumn}{#1}%
+  \csname recalctypearea\endcsname
+}
+\KOMA@DeclareObsoleteOption[\PackageInfo]{onecolumn}{twocolumn=false}
+\KOMA@key{pagesize}[auto]{%
+  \begingroup
+    \KOMA@set@ncmdkey{pagesize}{@tempa}{%
+      {auto}{0},{automedia}{1},{dvips}{2},{pdftex}{3}%
+    }{#1}%
+    \ifcase\number\@tempa\relax
+      \endgroup
+      \set@pdftexpagesize
+      \set@dvipspagesize
+    \or
+      \endgroup
+      \set@pdftexpagesize
+      \set@vtexpagesize
+      \set@dvipspagesize
+    \or
+      \endgroup
+      \set@dvipspagesize
+    \or
+      \endgroup
+      \set@pdftexpagesize
+  \fi
+  \edef\@pagesizelast{#1}%
+}
+\newcommand{\set@pdftexpagesize}{%
+  \AtBeginDocument{%
+    \ifnotundefined{pdfpagewidth}{\pdfpagewidth=\paperwidth}{}%
+    \ifnotundefined{pdfpageheight}{\pdfpageheight=\paperheight}{}%
+  }%
+  \let\set@pdftexpagesize=\@empty
+}
+\newcommand{\set@dvipspagesize}{%
+  \begingroup
+    \@tempswafalse
+    \scr@ifdvioutput{\@tempswatrue}{%
+      \ifnotundefined{if@dvips}{\let\if@tempswa\if@dvips}{}%
+    }%
+    \if@tempswa
+      \endgroup
+      \AtBeginDocument{\AtBeginDvi{%
+          \special{papersize=\the\paperwidth,\the\paperheight}%
+        }%
+      }%
+      \let\set@dvipspagesize=\setnot@dvipspagesize
+    \else
+      \endgroup
+  \fi
+}
+\newcommand{\setnot@dvipspagesize}{%
+  \scr@ifdvioutput{%
+    \PackageWarning{%
+      typearea%
+    }{%
+      With dvi output option `pagesize=auto',\MessageBreak
+      `pagesize=automedia' or `pagesize=dvips'\MessageBreak
+      may be used only once at preamble.\MessageBreak
+      Option ignored%
+    }%
+  }{}%
+}
+\newcommand{\set@vtexpagesize}{%
+  \AtBeginDocument{%
+    \ifnotundefined{mediawith}{\mediawidth=\paperwidth}{}%
+    \ifnotundefined{mediaheight}{\mediaheight=\paperheight}{}%
+  }%
+  \let\set@vtexpagesize=\@empty
+}
+\AtBeginDocument{
+  \renewcommand*{\set@pdftexpagesize}{%
+    \ifnotundefined{pdfpagewidth}{\pdfpagewidth=\paperwidth}{}%
+    \ifnotundefined{pdfpageheight}{\pdfpageheight=\paperheight}{}%
+  }%
+  \let\set@dvipspagesize=\setnot@dvipspagesize
+  \renewcommand*{\set@vtexpagesize}{%
+    \ifnotundefined{mediawith}{\mediawidth=\paperwidth}{}%
+    \ifnotundefined{mediaheight}{\mediaheight=\paperheight}{}%
+  }%
+}
+\KOMA@DeclareObsoleteOption[\PackageWarning]{dvips}{%
+  pagesize=dvips%
+}
+\KOMA@DeclareObsoleteOption[\PackageInfo]{pdftex}{%
+  pagesize=pdftex%
+}
+\KOMA@DeclareObsoleteOption[\PackageInfo]{a4paper}{paper=a4}
+\KOMA@DeclareObsoleteOption[\PackageInfo]{a5paper}{paper=a5}
+\KOMA@DeclareObsoleteOption[\PackageInfo]{b5paper}{paper=b5}
+\KOMA@DeclareObsoleteOption[\PackageInfo]{letterpaper}{paper=letter}
+\KOMA@DeclareObsoleteOption[\PackageInfo]{legalpaper}{paper=legal}
+\KOMA@DeclareObsoleteOption[\PackageInfo]{executivepaper}{paper=executive}
+\KOMA@DeclareObsoleteOption[\PackageInfo]{landscape}{paper=landscape}
+\KOMA@DeclareObsoleteOption[\PackageInfo]{portrait}{paper=portrait}
+\KOMA@key{paper}{%
+  \ifstr{#1}{landscape}{%
+    \if@landscape\else
+      \setlength{\@tempdima}{\paperwidth}%
+      \setlength{\paperwidth}{\paperheight}%
+      \setlength{\paperheight}{\@tempdima}%
+      \@landscapetrue
+    \fi
+  }{%
+    \ifstr{#1}{portrait}{%
+      \if@landscape
+        \setlength{\@tempdima}{\paperwidth}%
+        \setlength{\paperwidth}{\paperheight}%
+        \setlength{\paperheight}{\@tempdima}%
+        \@landscapefalse
+      \fi
+    }{%
+      \ifstr{#1}{letter}{%
+        \setlength\paperheight{11in}%
+        \setlength\paperwidth {8.5in}%
+      }{%
+        \ifstr{#1}{legal}{%
+          \setlength\paperheight{14in}%
+          \setlength\paperwidth {8.5in}%
+        }{%
+          \ifstr{#1}{executive}{%
+            \setlength\paperheight{10.5in}%
+            \setlength\paperwidth {7.25in}%
+          }{%
+            \iso@paper{#1}%
+            \if@tempswa\else
+              \expandafter\maybe@pair#1\scr@next
+              \if@tempswa
+                \setlength\paperheight{\@tempa}%
+                \setlength\paperwidth{\@tempb}%
+              \else
+                \KOMA@unknown@keyval{paper}{#1}{%
+                  `letter', `legal', `executive', `a'<nr>, `b'<nr>,
+                  `c'<nr>, `d'<nr>,\MessageBreak
+                  `('<width>`,'<height>`)', `landscape' and `portrait'%
+                }%
+              \fi
+            \fi
+          }%
+        }%
+      }%
+      \if@landscape
+        \setlength{\@tempdima}{\paperwidth}%
+        \setlength{\paperwidth}{\paperheight}%
+        \setlength{\paperheight}{\@tempdima}%
+      \fi
+    }%
+  }%
+}
 \newif\if@landscape
-\DeclareOption{landscape}{\@landscapetrue}
-\DeclareOption{DIVcalc}{\ta@div=1\relax}
-\DeclareOption{DIVclassic}{\ta@div=3\relax}
-\DeclareOption*{\x@paper}
-\InputIfFileExists{typearea.cfg}
-           {\typeout{***************************************^^J%
-                     * Local config file typearea.cfg used^^J%
-                     ***************************************}}
-           {}
-\ExecuteOptions{headexclude,footexclude,a4paper}
-\ProcessOptions\relax
-\if@landscape
- \setlength\@tempdima   {\paperheight}
- \setlength\paperheight {\paperwidth}
- \setlength\paperwidth  {\@tempdima}
-\fi
+\newcommand*{\maybe@pair}{%
+  \@ifnextchar (%
+  {\@tempswatrue\maybe@@pair}{\@tempswafalse\gobble@till@scr@next}%
+}
+\newcommand*{\maybe@@pair}{}
+\def\@maybepair(#1,#2)\scr@next{\def\@tempa{#1}\def\@tempb{#2}}%
+\InputIfFileExists{typearea.cfg}{%
+  \typeout{%
+    ***************************************^^J%
+    * Local config file typearea.cfg used^^J%
+    ***************************************%
+  }
+}{}
+\DeclareKeyValOption[\x@paper]{KOMA}
+\KOMAoptions{headinclude=false,footinclude=false,paper=A4}
+\ProcessAllOptions{KOMA}
 \providecommand\ta@divlist{{}{}{}{}{}{}{}{}{}{8}{10}{12}}
 \providecommand\ta@divlistelse{1}
 \newlength{\ta@hblk}
 \newlength{\ta@vblk}
 \newlength{\ta@temp}
-\newcommand*\@typearea{
- \ta@hblk \paperwidth
- \advance \ta@hblk by -\ta@bcor
- \divide\ta@hblk by \ta@div
- \if@mincl
-  \marginparwidth \ta@hblk
-  \advance\marginparwidth -\marginparsep
- \else
+\newcommand*\@typearea{%
+  \selectfont
+  \ta@hblk=\paperwidth
+  \advance \ta@hblk by-\ta@bcor
+  \divide\ta@hblk by\ta@div
+  \if@mincl
+    \marginparwidth=\ta@hblk
+    \advance\marginparwidth by-\marginparsep
+  \else
+    \if@twoside
+      \marginparwidth=1.5\ta@hblk
+    \else
+      \marginparwidth=\ta@hblk
+    \fi
+  \fi
+  \oddsidemargin=-1in
+  \evensidemargin=-1in
   \if@twoside
-   \marginparwidth 1.5\ta@hblk
+    \advance\oddsidemargin by\ta@hblk
+    \advance\oddsidemargin by\ta@bcor
+    \advance\evensidemargin by2\ta@hblk
+    \if@mincl
+      \advance\evensidemargin by\marginparwidth
+      \advance\evensidemargin by\marginparsep
+    \fi
   \else
-   \marginparwidth \ta@hblk
+    \advance\oddsidemargin by1.5\ta@hblk
+    \advance\oddsidemargin by\ta@bcor
+    \evensidemargin=\oddsidemargin
   \fi
- \fi
- \oddsidemargin -1in
- \evensidemargin -1in
- \if@twoside
-  \advance\oddsidemargin by \ta@hblk
-  \advance\oddsidemargin by \ta@bcor
-  \advance\evensidemargin by 2\ta@hblk
+  \textwidth=\paperwidth
+  \advance\textwidth by-\ta@bcor
+  \advance\textwidth by-3\ta@hblk
   \if@mincl
-    \advance\evensidemargin by \marginparwidth
-    \advance\evensidemargin by \marginparsep
+    \advance\textwidth by-\marginparwidth
+    \advance\textwidth by-\marginparsep
+    \ifdim\textwidth <\marginparwidth
+      \PackageWarningNoLine{typearea}{%
+        Width of text (\the\textwidth) less than width of\MessageBreak
+        marginpar (\the\marginparwidth) while using option\MessageBreak
+        `mpinclude'.\MessageBreak
+        Because of this, I'm exchanging the values.\MessageBreak
+        You should increase DIV to avoid such problems.\MessageBreak
+      }%
+      \@tempskipa=\marginparwidth
+      \marginparwidth=\textwidth
+      \textwidth=\@tempskipa
+    \fi
   \fi
- \else
-  \advance\oddsidemargin by 1.5\ta@hblk
-  \advance\oddsidemargin by \ta@bcor
-  \evensidemargin\oddsidemargin
- \fi
- \textwidth \paperwidth
- \advance\textwidth by -\ta@bcor
- \advance\textwidth by -3\ta@hblk
- \if@mincl
-  \advance\textwidth by -\marginparwidth
-  \advance\textwidth by -\marginparsep
-  \ifdim\textwidth <\marginparwidth
-    \PackageWarningNoLine{typearea}{%
-      Width of text (\the\textwidth) less than width of\MessageBreak
-      marginpar (\the\marginparwidth) while using option\MessageBreak
-      `mpinclude'.\MessageBreak
-      Because of this, I'm exchanging the values.\MessageBreak
-      You should increase DIV to avoid such problems.\MessageBreak
-      }
-    \@tempdima \marginparwidth
-    \marginparwidth \textwidth
-    \textwidth \@tempdima
+  \ta@vblk=\paperheight
+  \divide\ta@vblk by\ta@div
+  \topmargin=-1in
+  \advance\topmargin by\ta@vblk
+  \if@hincl \else
+    \advance\topmargin by-\headheight
+    \advance\topmargin by-\headsep
+  \fi
+  \ta@temp=\paperheight
+  \advance\ta@temp by-3\ta@vblk
+  \if@hincl
+    \advance\ta@temp by-\headheight
+    \advance\ta@temp by-\headsep
+  \fi
+  \if@fincl
+    \advance\ta@temp by-\footskip
   \fi
- \fi
- \ta@vblk \paperheight
- \divide\ta@vblk by \ta@div
- \topmargin -1in
- \advance\topmargin by \ta@vblk
- \if@hincl \else
-  \advance\topmargin by -\headheight
-  \advance\topmargin by -\headsep
- \fi
- \ta@temp \paperheight
- \advance\ta@temp by -3\ta@vblk
- \if@hincl
-  \advance\ta@temp by -\headheight
-  \advance\ta@temp by -\headsep
- \fi
- \if@fincl
-  \advance\ta@temp by -\footskip
- \fi
- \textheight \topskip
- \@whiledim\textheight<\ta@temp
-  \do{\advance\textheight by \baselineskip}
+  \textheight=\topskip
+  \@whiledim\textheight <\ta@temp
+  \do{\advance\textheight by\baselineskip}%
 }
 \newcommand*\ta@modiv[2]{
- \setlength{\@tempdima}{#1}
- \divide\@tempdima by#2\relax
- \ta@div\@tempdima
- \ifnum \ta@div<4\relax
-  \ta@div=4\relax
- \else
-  \setlength{\@tempdimb}{#1}
-  \divide\@tempdimb\ta@div
-  \addtolength{\@tempdima}{\@tempdima}
-  \addtolength{\@tempdima}{-\@tempdimb}
-  \advance\ta@div\@ne
-  \setlength{\@tempdimb}{#1}
-  \divide\@tempdimb\ta@div
-  \ifdim \@tempdima<\@tempdimb
-   \advance\ta@div by\m@ne
+  \setlength{\@tempdima}{#1}
+  \divide\@tempdima by#2
+  \ta@div\@tempdima
+  \ifnum \ta@div<4
+    \ta@div=4
+  \else
+    \setlength{\@tempdimb}{#1}%
+    \divide\@tempdimb by\ta@div
+    \addtolength{\@tempdima}{\@tempdima}%
+    \addtolength{\@tempdima}{-\@tempdimb}%
+    \advance\ta@div by\@ne
+    \setlength{\@tempdimb}{#1}%
+    \divide\@tempdimb by\ta@div
+    \ifdim \@tempdima<\@tempdimb
+      \advance\ta@div by\m@ne
+    \fi
   \fi
- \fi
 }
-\newcommand*\ta@temp@goodwidth{
+\newcommand*\ta@temp@goodwidth{%
   \settowidth{\ta@temp}{\normalfont\normalsize
-    abcdefghijklmnopqrstuvwxyz}
+    abcdefghijklmnopqrstuvwxyz}%
   \ifdim\ta@temp >200\p@
-    \divide\ta@temp by 26
-    \multiply\ta@temp by 3
+    \setlength{\ta@temp}{2.53846\ta@temp}%
     \settowidth{\@tempdima}{\normalfont\normalsize
-      ABCDEFGHIJKLMNOPQRSTUVWXYZ}
-    \divide\@tempdima by 26
-    \multiply\@tempdima by 3
-    \addtolength{\ta@temp}{\@tempdima}
+      ABCDEFGHIJKLMNOPQRSTUVWXYZ}%
+    \setlength{\@tempdima}{.11538\@tempdima}%
+    \addtolength{\ta@temp}{\@tempdima}%
   \else
-    \multiply\ta@temp by 66
+    \multiply\ta@temp by66
     \settowidth{\@tempdima}{\normalfont\normalsize
-      ABCDEFGHIJKLMNOPQRSTUVWXYZ}
-    \multiply\@tempdima by 3
-    \addtolength{\ta@temp}{\@tempdima}
-    \divide\ta@temp by 26
+      ABCDEFGHIJKLMNOPQRSTUVWXYZ}%
+    \multiply\@tempdima by3
+    \addtolength{\ta@temp}{\@tempdima}%
+    \divide\ta@temp by26
   \fi
 }
-\newcommand*\typearea[2][\z@]{
-  \edef\@tempa{#1}\edef\@tempb{current}\ifx\@tempa\@tempb\else
-    \setlength{\ta@bcor}{#1}
-  \fi
-  \edef\@tempa{#2}
-  \def\@tempb{last}\ifx\@tempa\@tempb\let\@tempa=\@lastdiv\fi
-  \def\@tempb{current}\ifx\@tempa\@tempb\else
-    \def\@tempb{default}\ifx\@tempa\@tempb\ta@div=0\relax\else
-      \def\@tempb{calc}\ifx\@tempa\@tempb\ta@div=2\relax\else
-        \def\@tempb{classic}\ifx\@tempa\@tempb\ta@div=3\relax\else
-          \ta@div=\@tempa\relax
-        \fi
-      \fi
+\AtBeginDocument{%
+  \newcommand\@typearea@end{%
+    \PackageWarning{typearea}{%
+      Typearea changed!\MessageBreak
+      You should do this only at preamble, because only\MessageBreak
+      \protect\begin{document} calculates output dimensions!\MessageBreak
+      Trying to calculate new output dimensions, but\MessageBreak
+      this is only a dirty hack}%
+    \@colht=\textheight
+    \@colroom=\textheight
+    \vsize=\textheight
+    \columnwidth=\textwidth
+    \if@twocolumn
+      \advance\columnwidth by-\columnsep
+      \divide\columnwidth by\tw@
+      \hsize=\columnwidth
+      \@firstcolumntrue
     \fi
-  \fi
-  \edef\@lastdiv{\the\ta@div}
-  \@ifundefined{ta@hh}{\headheight 1.25\baselineskip}{\headheight\ta@hh}
- \headsep 1.5\baselineskip
- \footskip 3.5\baselineskip
- \marginparsep 1cc
- \marginparpush 0.45\baselineskip
- \ifnum\ta@div=\z@
-  \@ifundefined{@ptsize}{%
-   \@tempdima=\f@size pt\relax
-   \advance\@tempdima by.5pt
-   \ta@div=\@tempdima
-   \divide\ta@div by65536\relax
-   \advance\ta@div by-10\relax
-   \xdef\@ptsize{\the\ta@div}%
-   \PackageWarningNoLine{typearea}{%
-     \string\@ptsize\space not defined!
-     \MessageBreak
-     Fontsize ist \f@size.\MessageBreak
-     Defining \string\@ptsize\space to \@ptsize}%
-   }{}
-  \ta@divfor{\@ptsize}%
- \fi
- \ifnum\ta@div=3
-  \typeout{DIV calculation for classic typearea.}
-  \setlength{\ta@temp}{\paperwidth}
-  \addtolength{\ta@temp}{-\ta@bcor}
-  \if@hincl\else
-   \addtolength{\ta@temp}{\headheight}
-   \addtolength{\ta@temp}{\headsep}
-  \fi
-  \if@fincl\else
-   \addtolength{\ta@temp}{\footskip}
-  \fi
-  \ifdim \ta@temp>\paperheight
-   \PackageWarningNoLine{typearea}
-    {No classic typearea with this papersize!\MessageBreak
-     Using calculated DIV}
-   \ta@div=\@ne
+    \hsize=\columnwidth
+    \linewidth\hsize
+    \ifundefined{@pagesizelast}{}{\KOMAoptions{pagesize=\@pagesizelast}}%
+  }%
+}
+\newcommand*{\ta@divfor}[1]{%
+  \if@mincl
+    \PackageInfo{typearea}{%
+      With option `mpinclude' there are no predefined\MessageBreak
+      DIV-values. Using DIV calculation for good line\MessageBreak
+      width%
+    }%
+    \ta@div=2
   \else
-   \setlength{\ta@temp}{\paperheight}
-   \addtolength{\ta@temp}{-\paperwidth}
-   \addtolength{\ta@temp}{\ta@bcor}
-   \divide\ta@temp 3\relax
-   \ta@modiv{\paperheight}{\ta@temp}
-  \fi
- \fi
- \ifnum\ta@div<4
-  \typeout{DIV calculation for typearea with good linewidth.}
-  \setlength{\textwidth}{\paperwidth}
-  \addtolength{\textwidth}{-\ta@bcor}
-  \ta@temp@goodwidth
-  \if@twocolumn
-    \addtolength{\ta@temp}{\ta@temp}
-    \addtolength{\ta@temp}{\columnsep}
+    \xdef\@tempa{\ta@divlist{}}%
+    \ta@div=#1\relax
+    \@whilenum \ta@div >-9 \do {%
+      \ifx\@tempa\empty
+      \else \xdef\@tempa{\expandafter\@cdr\@tempa\@nil}\fi
+      \advance\ta@div by-1
+    }%
+    \ifx\@tempa\empty
+      \ta@div=10 \advance\ta@div by#1
+      \PackageWarningNoLine{typearea}{%
+        DIV for \the\ta@div pt and used papersize\MessageBreak
+        not defined!\MessageBreak
+        Using DIV=\ta@divlistelse
+      }%
+      \ta@div=\ta@divlistelse\relax
+    \else
+      \xdef\@tempa{\expandafter\@car\@tempa\@nil}%
+      \ifx\@tempa\empty
+        \ta@div=\ta@divlistelse\relax
+      \else
+        \ta@div=\@tempa\relax
+      \fi
+    \fi
   \fi
-  \setlength{\ta@hblk}{\paperwidth}
-  \addtolength{\ta@hblk}{-\ta@temp}
-  \divide\ta@hblk by 3
-  \ifdim \ta@hblk<\z@\relax
-    \setlength{\ta@hblk}{5mm}
+}
+\newcommand*\typearea[2][\z@]{%
+  \edef\@tempa{#1}\edef\@tempb{current}\ifx\@tempa\@tempb\else
+    \setlength{\ta@bcor}{#1}%
   \fi
-   \if@mincl
-     \setlength{\ta@temp}{.75\ta@hblk}
-   \else
-     \setlength{\ta@temp}{\ta@hblk}
-   \fi
-  \ta@modiv{\paperwidth}{\ta@temp}
-  \@typearea
-  \setlength{\ta@temp}{-1in}
-  \addtolength{\ta@temp}{5mm}
-  \ifdim\topmargin<\ta@temp
-   \setlength{\ta@temp}{15mm}
-   \if@hincl\else
-    \addtolength{\ta@temp}{\headheight}
-    \addtolength{\ta@temp}{\headsep}
-   \fi
-   \if@fincl\else
-    \addtolength{\ta@temp}{\footskip}
-   \fi
-   \divide\ta@temp by3\relax
-   \ta@modiv{\paperheight}{\ta@temp}
+  \edef\@tempa{#2}%
+  \def\@tempb{last}\ifx\@tempa\@tempb\let\@tempa=\@lastdiv
+    \ifx\csname @tempa\endcsname\relax
+      \def\@tempa{current}%
+    \fi
   \fi
- \fi
- \@typearea
- \ta@temp@goodwidth
- \if@twocolumn
-   \addtolength{\ta@temp}{\ta@temp}%
-   \addtolength{\ta@temp}{\columnsep}%
- \fi
- \setlength{\@tempdima}{\ta@temp}%
- \addtolength{\ta@temp}{-\textwidth}%
- \divide\@tempdima 100\relax
- \divide\ta@temp\@tempdima
- \@tempcnta\ta@temp
- \ifnum\@tempcnta<5\relax
-  \ifnum\@tempcnta>-5\relax
-   \@tempcnta=0
+  \def\@tempb{areaset}\ifx\@tempa\@tempb
+    \areaset[current]{\textwidth}{\textheight}%
   \else
-   \advance\@tempcnta 4
-  \fi
- \else
-  \advance\@tempcnta -4
- \fi
- \ifnum\@tempcnta<-15\relax
-  \PackageWarningNoLine{typearea}
-   {Bad DIV-value!\MessageBreak
-    You should decrease DIV, increase fontsize or\MessageBreak
-    change papersize}
- \else\ifnum\@tempcnta>15\relax
-  \PackageWarningNoLine{typearea}
-   {Bad DIV-value!\MessageBreak
-    You should increase DIV, decrease fontsize or\MessageBreak
-    change papersize}
- \fi\fi
- \ifnum\ta@div<6\relax
-  \PackageWarningNoLine{typearea}
-   {Very low DIV-value!\MessageBreak
-    DIV-values less than 6 result in textwidth/-height\MessageBreak
-    smaller than total marginwidth/-height.\MessageBreak
-    You should increase DIV, increase fontsize or\MessageBreak
-    change papersize}
- \fi
- \PackageInfo{typearea}{%
-    These are the values describing the layout:\MessageBreak
-    DIV\space\space=\space\number\ta@div\MessageBreak
-    BCOR\space=\space\the\ta@bcor\MessageBreak
-    \string\paperwidth\space\space\space\space\space\space=%
-                         \space\the\paperwidth\MessageBreak
-    \space\string\textwidth\space\space\space\space\space\space=%
-                         \space\the\textwidth\MessageBreak
-    \space\string\columnwidth\space\space\space\space=%
-                         \space\the\columnwidth\MessageBreak
-    \space\string\columnsep\space\space\space\space\space\space=%
-                         \space\the\columnsep\MessageBreak
-    \space DIV-departure\space\space\space=%
-                         \space\the\@tempcnta/100\MessageBreak
-    \space\string\evensidemargin\space=%
-                         \space\the\evensidemargin\MessageBreak
-    \space\string\oddsidemargin\space\space=%
-                         \space\the\oddsidemargin\MessageBreak
-    \string\paperheight\space\space\space\space\space=%
-                         \space\the\paperheight\MessageBreak
-    \space\string\textheight\space\space\space\space\space=%
-                         \space\the\textheight\MessageBreak
-    \space\string\topmargin\space\space\space\space\space\space=%
-                         \space\the\topmargin\MessageBreak
-    \space\string\headheight\space\space\space\space\space=%
-                         \space\the\headheight\MessageBreak
-    \space\string\headsep\space\space\space\space\space\space\space\space=%
-                         \space\the\headsep\MessageBreak
-    \space\string\topskip\space\space\space\space\space\space\space\space=%
-                         \space\the\topskip\MessageBreak
-    \space\string\footskip\space\space\space\space\space\space\space=%
-                         \space\the\footskip\MessageBreak
-    \space\string\baselineskip\space\space\space=%
-                         \space\the\baselineskip\MessageBreak
-  }
-  \@typearea@end}
-\newcommand\@typearea@end{}
-\AtBeginDocument{%
- \renewcommand\@typearea@end{%
-  \PackageWarning{typearea}
-   {Typearea changed!\MessageBreak
-    You should do this only at preamble, because only\MessageBreak
-    \protect\begin{document} calculates output dimensions!\MessageBreak
-    Trying to calculate new output dimensions, but\MessageBreak
-    this is only a dirty hack}
-  \clearpage
-  \@colht\textheight
-  \@colroom\textheight \vsize\textheight
-  \columnwidth\textwidth
-  \if@twocolumn
-    \advance\columnwidth -\columnsep
-    \divide\columnwidth\tw@ \hsize\columnwidth \@firstcolumntrue
+    \def\@tempb{current}\ifx\@tempa\@tempb\else
+      \def\@tempb{default}\ifx\@tempa\@tempb\ta@div=0 \else
+        \def\@tempb{calc}\ifx\@tempa\@tempb\ta@div=2 \else
+          \def\@tempb{classic}\ifx\@tempa\@tempb\ta@div=3 \else
+            \ta@div=\@tempa
+          \fi
+        \fi
+      \fi
+    \fi
+    \edef\@lastdiv{\the\ta@div}%
+    \if@atdocument\newpage\fi
+    \normalsize
+    \@ifundefined{ta@hh}{%
+      \headheight=1.25\baselineskip
+    }{%
+      \headheight=\ta@hh
+    }%
+    \headsep=1.5\baselineskip
+    \footskip=3.5\baselineskip
+    \marginparsep=1cc
+    \marginparpush=0.45\baselineskip
+    \ifnum\ta@div=\z@
+      \@ifundefined{@ptsize}{%
+        \@tempdima=\f@size pt
+        \advance\@tempdima by.5pt
+        \ta@div=\@tempdima
+        \divide\ta@div by65536
+        \advance\ta@div by-10
+        \xdef\@ptsize{\the\ta@div}%
+        \PackageWarningNoLine{typearea}{%
+          \string\@ptsize\space not defined!\MessageBreak
+          Fontsize ist \f@size.\MessageBreak
+          Defining \string\@ptsize\space to \@ptsize%
+        }%
+      }{}%
+      \ta@divfor{\@ptsize}%
+    \fi
+    \ifnum\ta@div=3
+      \typeout{DIV calculation for classic typearea.}%
+      \setlength{\ta@temp}{\paperwidth}%
+      \addtolength{\ta@temp}{-\ta@bcor}%
+      \if@hincl\else
+        \addtolength{\ta@temp}{\headheight}%
+        \addtolength{\ta@temp}{\headsep}%
+      \fi
+      \if@fincl\else
+        \addtolength{\ta@temp}{\footskip}%
+      \fi
+      \ifdim \ta@temp >\paperheight
+        \PackageWarningNoLine{typearea}{%
+          No classic typearea with this papersize!\MessageBreak
+          Using calculated DIV%
+        }%
+        \ta@div=\@ne
+      \else
+        \setlength{\ta@temp}{\paperheight}%
+        \addtolength{\ta@temp}{-\paperwidth}%
+        \addtolength{\ta@temp}{\ta@bcor}%
+        \divide\ta@temp by3
+        \ta@modiv{\paperheight}{\ta@temp}%
+      \fi
+    \fi
+    \ifnum\ta@div <4
+      \typeout{DIV calculation for typearea with good linewidth.}%
+      \setlength{\textwidth}{\paperwidth}%
+      \addtolength{\textwidth}{-\ta@bcor}%
+      \ta@temp@goodwidth
+      \if@twocolumn
+        \addtolength{\ta@temp}{\ta@temp}%
+        \addtolength{\ta@temp}{\columnsep}%
+      \fi
+      \setlength{\ta@hblk}{\paperwidth}%
+      \addtolength{\ta@hblk}{-\ta@temp}%
+      \divide\ta@hblk by3
+      \ifdim \ta@hblk <\z@
+        \setlength{\ta@hblk}{5mm}%
+      \fi
+      \if@mincl
+        \setlength{\ta@temp}{.75\ta@hblk}%
+      \else
+        \setlength{\ta@temp}{\ta@hblk}%
+      \fi
+      \ta@modiv{\paperwidth}{\ta@temp}%
+      \@typearea
+      \setlength{\ta@temp}{-1in}%
+      \addtolength{\ta@temp}{5mm}%
+      \ifdim\topmargin <\ta@temp
+        \setlength{\ta@temp}{15mm}%
+        \if@hincl\else
+          \addtolength{\ta@temp}{\headheight}%
+          \addtolength{\ta@temp}{\headsep}%
+        \fi
+        \if@fincl\else
+          \addtolength{\ta@temp}{\footskip}%
+        \fi
+        \divide\ta@temp by3
+        \ta@modiv{\paperheight}{\ta@temp}%
+      \fi
+    \fi
+    \@typearea
+    \ta@temp@goodwidth
+    \if@twocolumn
+      \addtolength{\ta@temp}{\ta@temp}%
+      \addtolength{\ta@temp}{\columnsep}%
+    \fi
+    \setlength{\@tempdima}{\ta@temp}%
+    \addtolength{\ta@temp}{-\textwidth}%
+    \divide\@tempdima by100
+    \divide\ta@temp by\@tempdima
+    \@tempcnta=\ta@temp
+    \ifnum\@tempcnta <5
+      \ifnum\@tempcnta >-5
+        \@tempcnta=0
+      \else
+        \advance\@tempcnta by4
+      \fi
+    \else
+      \advance\@tempcnta by-4
+    \fi
+    \ifnum\@tempcnta <-15
+      \PackageWarningNoLine{typearea}{%
+        Bad DIV-value!\MessageBreak
+        You should e.g. decrease DIV, increase fontsize\MessageBreak
+        or change papersize%
+      }%
+    \else
+      \ifnum\@tempcnta>15
+        \PackageWarningNoLine{typearea}{%
+          Bad DIV-value!\MessageBreak
+          You should e.g. increase DIV, decrease fontsize\MessageBreak
+          or change papersize%
+        }
+    \fi\fi
+    \ifnum\ta@div <6
+      \PackageWarningNoLine{typearea}{%
+        Very low DIV-value!\MessageBreak
+        DIV-values less than 6 result in textwidth/-height\MessageBreak
+        smaller than total marginwidth/-height.\MessageBreak
+        You should e.g. increase DIV, increase fontsize or\MessageBreak
+        change papersize%
+      }
+    \fi
+    \PackageInfo{typearea}{%
+      These are the values describing the layout:\MessageBreak
+      DIV\space\space=\space\number\ta@div\MessageBreak
+      BCOR\space=\space\the\ta@bcor\MessageBreak
+      \string\paperwidth\space\space\space\space\space\space=%
+                           \space\the\paperwidth\MessageBreak
+      \space\string\textwidth\space\space\space\space\space\space=%
+                           \space\the\textwidth\MessageBreak
+      \space DIV-departure\space\space\space=%
+                           \space\the\@tempcnta/100\MessageBreak
+      \space\string\evensidemargin\space=%
+                           \space\the\evensidemargin\MessageBreak
+      \space\string\oddsidemargin\space\space=%
+                           \space\the\oddsidemargin\MessageBreak
+      \string\paperheight\space\space\space\space\space=%
+                           \space\the\paperheight\MessageBreak
+      \space\string\textheight\space\space\space\space\space=%
+                           \space\the\textheight\MessageBreak
+      \space\string\topmargin\space\space\space\space\space\space=%
+                           \space\the\topmargin\MessageBreak
+      \space\string\headheight\space\space\space\space\space=%
+                           \space\the\headheight\MessageBreak
+      \space\string\headsep\space\space\space\space\space\space\space\space=%
+                           \space\the\headsep\MessageBreak
+      \space\string\topskip\space\space\space\space\space\space\space\space=%
+                           \space\the\topskip\MessageBreak
+      \space\string\footskip\space\space\space\space\space\space\space=%
+                           \space\the\footskip\MessageBreak
+      \space\string\baselineskip\space\space\space=%
+                           \space\the\baselineskip\MessageBreak
+    }%
+    \if@atdocument\@typearea@end\fi
   \fi
-  \hsize\columnwidth \linewidth\hsize
- }}
-\newcommand*\areaset[3][\z@]{
+}
+\AtEndOfPackage{\newcommand*{\recalctypearea}{\typearea[current]{last}}}
+\newcommand*\areaset[3][\z@]{%
   \edef\@tempa{#1}\edef\@tempb{current}\ifx\@tempa\@tempb\else
-    \setlength{\ta@bcor}{#1}
+    \setlength{\ta@bcor}{#1}%
   \fi
-  \textwidth #2
-  \textheight #3
-  \ta@hblk \paperwidth
-  \advance\ta@hblk by -\ta@bcor
-  \advance\ta@hblk by -\textwidth
-  \divide\ta@hblk by 3
-  \oddsidemargin -1in
-  \evensidemargin -1in
+    \if@atdocument\newpage\fi
+  \setlength{\textwidth}{#2}%
+  \setlength{\textheight}{#3}%
+  \def\@lastdiv{areaset}%
+  \ta@hblk=\paperwidth
+  \advance\ta@hblk by-\ta@bcor
+  \advance\ta@hblk by-\textwidth
+  \divide\ta@hblk by3
+  \oddsidemargin=-1in
+  \evensidemargin=-1in
   \if@twoside
-    \advance\oddsidemargin by \ta@hblk
-    \advance\oddsidemargin by \ta@bcor
-    \advance\evensidemargin by 2\ta@hblk
+    \advance\oddsidemargin by\ta@hblk
+    \advance\oddsidemargin by\ta@bcor
+    \advance\evensidemargin by2\ta@hblk
   \else
-    \advance\oddsidemargin by 1.5\ta@hblk
-    \advance\oddsidemargin by \ta@bcor
+    \advance\oddsidemargin by1.5\ta@hblk
+    \advance\oddsidemargin by\ta@bcor
     \evensidemargin\oddsidemargin
   \fi
-  \headheight 15\p@
+  \headheight=15\p@
   \advance\headheight by\f@size\p@
   \advance\headheight by-10\p@
-  \headsep 1.5\baselineskip
-  \footskip 3.5\baselineskip
-  \ta@vblk \paperheight
-  \advance\ta@vblk by -\textheight
-  \divide\ta@vblk by 3
+  \headsep=1.5\baselineskip
+  \footskip=3.5\baselineskip
+  \ta@vblk=\paperheight
+  \advance\ta@vblk by-\textheight
+  \divide\ta@vblk by3
   \if@hincl
-    \advance\textheight by -\headheight
-    \advance\textheight by -\headsep
+    \advance\textheight by-\headheight
+    \advance\textheight by-\headsep
   \fi
   \if@fincl
-    \advance\textheight by -\footskip
+    \advance\textheight by-\footskip
   \fi
   \topmargin \ta@vblk
-  \advance\topmargin by -1in
+  \advance\topmargin by-1in
   \if@hincl \else
-    \advance\topmargin by -\headheight
-    \advance\topmargin by -\headsep
+    \advance\topmargin by-\headheight
+    \advance\topmargin by-\headsep
   \fi
   \if@twoside
-    \marginparwidth 1.5\ta@hblk
+    \marginparwidth=1.5\ta@hblk
   \else
-    \marginparwidth \ta@hblk
+    \marginparwidth=\ta@hblk
   \fi
-  \marginparsep 1cc
-  \marginparpush 0.45\baselineskip
-  \@areaset@end}
-\newcommand\@areaset@end{\@typearea@end}
-\newcommand*{\ta@divfor}[1]{
-  \if@mincl
-    \PackageInfo{typearea}{%
-      With option `mpinclude' there are no predefined\MessageBreak
-      DIV-values. Using DIV calculation for good line\MessageBreak
-      width}
-    \ta@div=2
-  \else
-    \xdef\@tempa{\ta@divlist{}}
-    \ta@div=#1\relax
-    \@whilenum \ta@div >-9 \do {%
-      \ifx\@tempa\empty \relax%
-      \else \xdef\@tempa{\expandafter\@cdr\@tempa\@nil}%
-      \fi
-      \advance\ta@div by -1
-      }
-    \ifx\@tempa\empty
-      \ta@div=10\advance\ta@div by#1\relax
-      \PackageWarningNoLine{typearea}{%
-        DIV for \the\ta@div pt and used papersize\MessageBreak
-        not defined!\MessageBreak
-        Using DIV=\ta@divlistelse}
-      \ta@div=\ta@divlistelse\relax
-    \else
-      \xdef\@tempa{\expandafter\@car\@tempa\@nil}
-      \ifx\@tempa\empty
-        \ta@div=\ta@divlistelse\relax
-      \else
-        \ta@div=\@tempa\relax
-      \fi
-    \fi
-  \fi}
+  \marginparsep=1cc
+  \marginparpush=0.45\baselineskip
+  \if@atdocument\@typearea@end\fi
+}
 \typearea[current]{current}
+%%% From File: scrlogo.dtx
 \@ifundefined{KOMAScript}{%
   \DeclareRobustCommand{\KOMAScript}{\textsf{K\kern.05em O\kern.05em%
       M\kern.05em A\kern.1em-\kern.1em Script}}}{}
-- 
cgit v1.2.3

