
\setcounter{errorcontextlines}{100}
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesClass{vl-arbeitsanweisung}
    [2014/08/15 v0.1d Dokumentenklasse (RN/PTB)]
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{scrartcl}}
\ProcessOptions\relax
\PassOptionsToPackage{paper=a4,pagesize,twoside,headinclude}{typearea}

\LoadClass[%
,fontsize=12pt% ???
,headings=normal
,toc=bibliographynumbered
,captions=oneline
,captions=tableheading
%,origlongtable
]{scrartcl}

\RequirePackage{babel}
\RequirePackage{tabularx}
\let\ptb@endtabularx=\TX@endtabularx
\RequirePackage{amsmath,threeparttable,tabto,ltablex,grffile}
\RequirePackage{pdflscape,picture,trimspaces,url,varwidth,placeins}
\RequirePackage{zref-totpages,graphicx,booktabs,array,pdfpages}
\RequirePackage{longtable,siunitx,ragged2e,ifxetex,ifluatex,relsize}
\RequirePackage[manualmark]{scrpage2}

\let\ptb@tempdima=\@clnwd
\let\ptb@tempdimb=\@clnht
\let\ptb@tempdimc=\@dashdim

\newcommand*\ptb@Devision{}
\newcommand*\ptb@Department{}
\newcommand*\ptb@WorkingGroup{}
\newcommand*\ptb@Object{}
\newcommand*\ptb@Ident{}
\newcommand*\ptb@Edition{}
\newcommand*\ptb@Date{}
\newcommand*\ptb@tempa{0}

\newcommand*\Devision[1]{\xdef\ptb@Devision{\trim@spaces{#1}}}
\newcommand*\Department[1]{\xdef\ptb@Department{\trim@spaces{#1}}}
\newcommand*\WorkingGroup[1]{\xdef\ptb@WorkingGroup{\trim@spaces{#1}}}
\newcommand*\Object[1]{\xdef\ptb@Object{\trim@spaces{#1}}}
\newcommand*\Edition[1]{\xdef\ptb@Edition{\trim@spaces{#1}}}

\ifxetex
  \def\ptb@tempa{1}%
\else
  \ifluatex
    \def\ptb@tempa{1}%
  \fi
\fi

\ifcase\ptb@tempa % pdfTeX
  \RequirePackage[T1]{fontenc}
  \RequirePackage[utf8]{inputenc}
  \RequirePackage{textcomp}
  \RequirePackage{lmodern}
  \RequirePackage{tgpagella,qpxmath}
  %\RequirePackage{mathpazo}
  \RequirePackage{tgheros}
\or % Unicode (XeTeX oder luaTeX)
  \RequirePackage{fontspec,unicode-math}
  \setmainfont[Ligatures=TeX]{TeX Gyre Pagella}
  \setsansfont[Ligatures=TeX]{TeX Gyre Heros}
  \setmonofont[Scale=MatchLowercase]{Latin Modern Mono}
  \setmathfont{TeX Gyre Pagella Math}
\fi

\RequirePackage[
,final=true
,babel=true
]{microtype}

\RequirePackage[autostyle=true,babel=once,german=guillemets,maxlevel=3]{csquotes}%
\defineshorthand{"`}{\openautoquote}%
\defineshorthand{"'}{\closeautoquote}%
\MakeAutoQuote{»}{«}% Alt Gr + y / Alt Gr + x
\MakeAutoQuote{„}{“}% Alt Gr + v / Alt Gr + b

\newcommand*\ptb@rulewidth{.4mm}

\newcolumntype{C}{>{\centering}X}

\newcommand*\ptb@f@@t{%
  \begingroup
  \let\TX@endtabularx=\ptb@endtabularx
  \normalfont\sffamily\tiny\extrarowheight=.3\baselineskip
  \arrayrulewidth=\ptb@rulewidth \extratabsurround=0pt %
  \renewcommand*\tabularxcolumn[1]{m{##1}}%
  \begin{tabularx}{\textwidth}[t]{@{}|C|C|C|C|C|@{}} \firsthline
    Erstellt: \\
    Abteilung~\ptb@Devision, Fachbereich~\ptb@Department
  &
    Ausgabe-Nr.: \\ \ptb@Edition
  &
    Datum: \\ \ptb@Date
  &
    Kurzbezeichnung: \\ \ptb@Ident
  &
    Seite von Seiten \\ \thepage~von \ztotpages
  \tabularnewline \lasthline
  \end{tabularx}%
  \endgroup
}

\newcommand*\ptb@VWD[1]{%
  \begin{varwidth}{\linewidth}\centering #1\end{varwidth}}

\newcommand*\ptb@firstf@@t{%
\begingroup
  \let\TX@endtabularx=\ptb@endtabularx
  \normalfont\sffamily\tiny\extrarowheight=.3\baselineskip
  \arrayrulewidth=\ptb@rulewidth \extratabsurround=0pt %
  \renewcommand\tabularxcolumn[1]{m{##1}}%
  \begin{tabularx}{\textwidth}{@{}|C|C|C|c|c|c|@{}} \firsthline
    Erstellt: \\
    Abteilung~\ptb@Devision, Fachbereich~\ptb@Department \\
    AG~\ptb@WorkingGroup
  &
    Geprüft: \\ Leiter~\ptb@Department  \\~
  &
    Genehmigt: \\ QMV-\ptb@Devision \\~
  &
    \ptb@VWD{Ausgabe-Nr.: \\ \ptb@Edition\\~}
  &
    \ptb@VWD{Kurzbezeichnung: \\ \ptb@Ident\\~}
  &
    \ptb@VWD{Seite von Seiten \\ \thepage~von \ztotpages\\~}
  \tabularnewline

  &&&&& \tabularnewline
  &&&&& \tabularnewline

    am:~\dotfill
  &
    am:~\dotfill
  &
    am:~\dotfill
  &
  && \tabularnewline \lasthline
  \end{tabularx}%
  \endgroup
}

\AtBeginDocument{%
  \edef\ptb@Ident{\ptb@Department-AA-\ptb@Object}%
  \edef\ptb@Date{\@date}%
  \date{}%
}

\newcommand*\ptb@foot{%
  \ifnum\c@page=\@ne\ptb@firstf@@t\else\ptb@f@@t\fi
}
\newcommand*\ptb@head{%
  \begin{picture}(0,0)
    \linethickness{\ptb@rulewidth}%
    \put(0,-2.5mm){\line(1,0){\textwidth}}%
  \end{picture}
  \normalfont\sffamily\bfseries\large
  PTB\hfill Qualit\"atsmanagement-Arbeitsanweisung\hfill\ptb@Ident{}
}

\defpagestyle{headings}%
{%        Kopf
  %(OLL,OLD)% Linie
  {\ptb@head}% Gerade Seiten
  {\ptb@head}% Ungerade Seiten
  {% Einseitig
  }
  %(\textwidth,.8pt)% Linie
}%
{%        Fuss
  %(OLL,OLD)% Linie
  {\ptb@foot}% Gerade Seiten
  {\ptb@foot}% Ungerade Seiten
  {% Einseitig
  }
  %(\textwidth,2mm)% Linie
}

\RequirePackage[%
headheight=16mm,
marginparwidth=5mm,
left=22mm,
right=16mm,
textheight=225mm,
top=35mm,
headsep=14mm,
footskip=15mm,
]{geometry}

\renewcommand*\maketitle[1][1]{%
  \begingroup
  \centering \noindent\usekomafont{title}
    \Large \@title \par \bigskip\medskip
  \endgroup
}

\emergencystretch=3em %
\pagestyle{headings}
\def\titlepagestyle{headings}

\RequirePackage{tocstyle}
%\RequirePackage[tocflat]{tocstyle}
%\usetocstyle{KOMAlike}
\usetocstyle{allwithdot}
\settocfeature{raggedhook}{\raggedright}% verhindert auch Trennung
\settocfeature{pagenumberbox}{\makebox[1.5em][r]}
\settocfeature{entryhook}{\overfullrule=\z@}

\BeforeStartingTOC[toc]{\microtypesetup{protrusion=false}}
\AfterStartingTOC[toc]{\microtypesetup{protrusion=true}}

\addtokomafont{caption}{\small}
\addtokomafont{captionlabel}{\bfseries\sffamily}
\setcapindent{1em}
%\setcapwidth[c]{.8\textwidth}

\renewcommand{\floatpagefraction}{.9}
\renewcommand{\textfraction}{.1}
\renewcommand{\topfraction}{.9}
\renewcommand{\bottomfraction}{.5}
\setcounter{topnumber}{3}
\setcounter{bottomnumber}{1}
\setcounter{totalnumber}{5}
\renewcommand{\dbltopfraction}{.8}
\renewcommand{\dblfloatpagefraction}{.6}

% Einzelne Abbildungen nicht auf dem leeren Blatt zentrieren.
\setlength\@fptop{0pt}

% Kompaktere Listen

\RequirePackage[neverdecrease]{paralist}
\newcommand*\ptb@begin@list[1]{%
  \ptb@tempdima=\parindent
  \ptb@tempdimb=\parskip
  \@nameuse{#1}%
  \parindent=\ptb@tempdima
  \parskip=\ptb@tempdimb
}
\def\enumerate{%
  \ptb@begin@list{compactenum}%
}
\def\itemize{%
  \ptb@begin@list{compactitem}%
}
\def\description{%
  \ptb@begin@list{compactdesc}%
}
\let\enditemize\endcompactitem
\let\endenumerate\endcompactenum
\let\enddescription\endcompactdesc
\pltopsep=\medskipamount
\plitemsep=\medskipamount

\DeclareSIUnit\torr{Torr}
\DeclareSIUnit\mbar{\milli bar}

\sisetup{% Formatierung von Maßzahlen (z.B. Spaltentyp "S" in Tabellen)
  ,retain-zero-exponent=true
  ,retain-unity-mantissa=true
  ,add-decimal-zero=true
  ,add-integer-zero=true
  ,zero-decimal-to-integer=false
}

\addto\extrasgerman{\sisetup{locale=DE}}
\addto\extrasngerman{\sisetup{locale=DE}}
\addto\extrasenglish{\sisetup{locale=US}}

\renewcommand*\tabularxcolumn[1]{m{#1}}% vert. zentriert
\keepXColumns

\newcommand\tabsection[1]{%
  \multicolumn{\LT@cols}{@{}l@{}}{}\\[-.5em]
  \multicolumn{\LT@cols}{@{}l@{}}%
    {\makebox[0pt][l]{\parbox[b]{\TX@target}{%
      \usekomafont{disposition}#1}}} \\*[.25em]}

\raggedbottom

\RequirePackage[final]{hyperref}

\endinput
%%
%% End of file `arbeitsanweisung.cls'.

Zu ltablex-Problemen:

http://www.latex-community.org/forum/viewtopic.php?f=45&p=39984
(Axel Sommerfeld)

