% Rolf Niepraschk, Rolf.Niepraschk@ptb.de

\setcounter{errorcontextlines}{100}  \listfiles

\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesClass{pt-declaration}
    [2016/10/17 v0.1b PTB-Klasse (RN)]

\newcommand*\vl@lang{main=ngerman}

\DeclareOption{german}{\def\vl@lang{main=ngerman}}
\DeclareOption{ngerman}{\def\vl@lang{main=ngerman}}
\DeclareOption{de}{\def\vl@lang{main=ngerman}}
\DeclareOption{english}{\def\vl@lang{main=english}}
\DeclareOption{en}{\def\vl@lang{main=english}}
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{scrartcl}}

\ProcessOptions\relax

\LoadClass[%
,paper=a4
,fontsize=11pt
,parskip=true
]{scrartcl}

\RequirePackage{eso-pic,graphicx,xcolor}

\RequirePackage[\vl@lang]{babel}
\RequirePackage{iflang}


\RequirePackage[left=25mm,right=25mm,top=2cm,bottom=6cm]{geometry}

\RequirePackage{ifxetex,ifluatex,url,array,tabularx}
\newif\ifXeOrLua \XeOrLuafalse
\ifxetex\XeOrLuatrue\else\ifluatex\XeOrLuatrue\fi\fi

% TODO: Mathematik?
\ifXeOrLua% XeLaTeX oder luaLaTeX
  \RequirePackage{fontspec}
  \setmainfont{TeX Gyre Pagella}[Ligatures=TeX]
  \setsansfont{TeX Gyre Heros}[Scale=MatchUppercase,Ligatures=TeX]
  \setmonofont{AnonymousPro-Regular}[%
    Extension = .ttf,
    BoldFont = AnonymousPro-Bold,
    ItalicFont = AnonymousPro-Italic,
    BoldItalicFont = AnonymousPro-BoldItalic,
    Scale     = MatchLowercase
  ]
\else
  \RequirePackage[utf8]{inputenc}
  \RequirePackage[T1]{fontenc}
  \RequirePackage{textcomp}
  \RequirePackage{mathpazo}
  \RequirePackage{tgpagella}
  \RequirePackage{tgheros}
  \RequirePackage[ttdefault=true,scale=1.034]{AnonymousPro}
\fi

\RequirePackage{amsfonts,trimspaces}

\newcommand*\vl@setcommand[3][]{%  #1=default (opt.), #2=macro, #3=value
  \edef\vl@tempa{\trim@spaces@noexp{#3}}%
  \expandafter\protected@xdef\csname #2\endcsname{%
    \ifx\@empty\vl@tempa #1\else\vl@tempa\fi}%
}

\newcommand*\myref[1]{\vl@setcommand{vl@myref}{#1}}
\newcommand*\mymail[1]{\vl@setcommand{vl@mymail}{#1}}
\newcommand*\myfax[1]{\vl@setcommand{vl@myfax}{#1}}
\newcommand*\myemail[1]{\vl@setcommand{vl@myemail}{#1}}
\newcommand*\yourref[1]{\vl@setcommand{vl@yourref}{#1}}
\newcommand*\missingEntries[1]{\vl@setcommand{vl@missingEntries}{#1}}
\newcommand*\vl@myref{}
\newcommand*\vl@mymail{}
\newcommand*\vl@myfax{}
\newcommand*\vl@myemail{}
\newcommand*\vl@yourref{}
\newcommand*\vl@missingEntries{0}

\newcolumntype{Y}{>{\centering\arraybackslash}X}
\newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}

\AtBeginDocument{%
  \RequirePackage{paralist}
  \newcommand*\vl@begin@list[1]{%
    %\vl@tempdima=\parindent
    %\vl@tempdimb=\parskip
    \@nameuse{#1}%
    %\parindent=\vl@tempdima
    %\parskip=\vl@tempdimb
  }
  \def\enumerate{%
    \vl@begin@list{compactenum}%
  }
  \def\itemize{%
    \vl@begin@list{compactitem}%
  }
  \def\description{%
    \vl@begin@list{compactdesc}%
  }
  \let\enditemize\endcompactitem
  \let\endenumerate\endcompactenum
  \let\enddescription\endcompactdesc
  \pltopsep=\medskipamount
  \plitemsep=\medskipamount
  \setlength\leftmargini{1.5em}
  \setlength\leftmarginii{1.1em}
  \setlength\leftmarginiii{1.1em}
  \setlength\leftmarginiv{1.1em}
  \setlength\labelsep{.5em}

  \ifxetex\else
    \RequirePackage[%
    ,factor=1500
    ,protrusion=true
    ,expansion=true
    ,verbose=true
    ,final=true
    ,letterspace=100
    ,babel=true
    ]{microtype}
  \fi

  \makeatletter
  \IfLanguageName{ngerman}{%
    \input{ptb-declaration-de.clo}
  }{%
    \input{ptb-declaration-en.clo}
  }
  \makeatother
}

\newcommand*\checkBox[2][0]{%
  \begingroup
    \fboxrule=0.7bp\fboxsep=0pt % 0.7bp (10pt)
    \raisebox{.3\height}{\fbox{\parbox[c][11bp]{11bp}{%
      \mbox{}\ifcase#1\or\centering\relscale{1.35}$\times$\fi%
    }}}%
  \endgroup\ifx\relax#2\relax\else~\raisebox{.2\height}{#2}\fi%
}

\AtBeginDocument{%
  \ifnum\number\vl@missingEntries>0 %
    \AddToShipoutPictureBG{%
      \AtTextCenter{%
        \makebox(0,0)[c]{\resizebox{\textwidth}{!}{%
          \rotatebox{54.7}{%
            \textnormal{\textsf{\textbf{%
              \color{lightgray}Fehler:~\vl@missingEntries}}}}}}%
      }%
    }%
  \fi
}


\textheight=1.2\textheight
\pagestyle{empty}

\endinput
