% Rolf Niepraschk, Rolf.Niepraschk@ptb.de

\setcounter{errorcontextlines}{100}  \listfiles

\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesClass{ptp-declaration}
    [2021/06/14 v0.1c 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{enumitem}
  \setlist{leftmargin=*,itemsep=.3ex,parsep=.5ex}
  \setlist[1]{labelindent=1em}
  \iffalse
  \setlist[itemize,1]{label=\raisebox{-.1ex}{\Large\textbullet}}
  \setlist[itemize,2]{label=\raisebox{-.1ex}{\Large$\m@th\circ$}}
  \setlist[itemize,3]{label=\raisebox{-.7ex}{\large\textasteriskcentered}}
  \setlist[itemize,4]{label=\raisebox{.4ex}{\tiny$\m@th\triangleright$}}
  \fi

  \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