\NeedsTeXFormat{LaTeX2e}[1998/12/01]
\ProvidesClass{%
  mpiletter-inf%
  }% [2005/06/16 Max-Planck-Institut für Informatik SB Business Letter Class $Revision: 1.11 $ ]
% Written by Christoph Clodo (chcl@mpi-inf.mpg.de) June 2005
%  
% Converted for Debian 9  and new Komascript Wolfram Wagner (ww@mpi-klsb.mpg.de_ March 2018)
%
% Converted for 2023 INF logos, German and English version wit different sizes.
% Also better match of DIN 5008 letter norm, ISO date representation, requred for international letters
% Date set into a position above subject line, in the sender info block.
% Position of logo as close as possible to the MPG guidelines.
% Wolfram Wagner (ww@mpi-klsb.mpg.de 2023-09-19)
% 
% $Id: mpiletter-inf.cls,v 1.11 2023/09/20 09:53:36 ww Exp $

% This class is based on the KOMA scrlttr2.cls
% If you do not know KOMA or do not understand the concept of \LoadClass
% then DO NOT TOUCH THIS FILE!!!

%\typeout{}

% Memo to self: Next time discover textpos.sty four weeks earlier.

% Options
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Redirect all unknown options to KOMA
% BEFORE \DeclareOption*{}, such that user input may override class default
% parskip: paragraph skip
% fromlogo: turn on user defined letter head
% war: \newcommand{\charset}{isolatin}
  \usepackage[space]{grffile}
  \usepackage{merriweather}
  \usepackage{scrdate}
\DeclareOption{utf8}{
  \renewcommand{\charset}{utf8}
}
% utf8 was not set, use old default isolatin instead
\providecommand{\charset}{isolatin}
\PassOptionsToClass{parskip=full*,fromlogo=true}{scrlttr2}
% AFTER \PassOptionsToClass{}, such that user input may override class default
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{scrlttr2}}

%xxx nach loadclass und command defs, damit \setkomavar et al definiert ist?
% non KOMA options
%\DeclareOption{}{}
% Default Options
\ExecuteOptions{}
\ProcessOptions
\LoadClass{scrlttr2}

% External Packages
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\RequirePackage{graphicx}
\RequirePackage{hyperref}
% \usepackage[style=iso]{datetime2}
\urlstyle{same}
% Since typearea does not permit strict margins we use geometry
\RequirePackage{geometry}
% MPG Design Guide requirements for alternative fonts

\RequirePackage[\charset]{inputenc}
%\RequirePackage[isolatin]{inputenc}
% \RequirePackage{times}
% Times Courier looks just awful, use Computer Modern Typewriter instead
\def\ttdefault{cmtt}
% teTeX-3.x compatibility since \pdfoutput is no more \undefined but "0" :(
\RequirePackage{ifpdf}
% Tracing via \traceon \traceoff
%\RequirePackage{trace}
\RequirePackage[draft=true]{scrlayer}

% Layout definitions
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% MPG Design Guide requirements for margins
% Perhaps explicit MPI.lco one day
% DIN.lco Must be loaded first (actually default)
\LoadLetterOption{DIN}
\@newplength{infocolwidth}
% \@setplength{infocolwidth}{47mm}
\@setplength{infocolwidth}{57mm}
% The MPI-Inf paper is a bit faulty
\@newplength{mpipapercorrection}
\@setplength{mpipapercorrection}{2mm}
\@addtoplength{infocolwidth}{\useplength{mpipapercorrection}}
% Define right margin
\@newplength{rmargin}
% \@setplength{rmargin}{\useplength{infocolwidth}}
\@setplength{rmargin}{2cm}
% geometry is a bit stupid
\@addtoplength{rmargin}{1mm}
\geometry{left=20mm,right=\useplength{rmargin}}
% Give the user full manual control over how much text to cram onto the page
\footskip=10mm
\textheight=0.8\paperheight
%
% Correction of 11mm needed because of the backaddress alignment with the logo
\@newplength{behrvskip}\@setplength{behrvskip}{1mm}
\@newplength{behrfoldmarkvskip}
\@setplength{behrfoldmarkvskip}{\useplength{behrvskip}}
\@addtoplength{behrfoldmarkvskip}{7mm}
% All lengths as defined in DIN.lco
\@setplength{toaddrvpos}{45mm}
\@setplength{refvpos}{98.5mm}
\@setplength{tfoldmarkvpos}{105mm}
\@setplength{bfoldmarkvpos}{210mm}
% To make the backaddress suit the logo
\@addtoplength[-]{toaddrvpos}{\useplength{behrvskip}}
% Leave this vpos as it is. Otherwise the date will collide with
% the backaddress
\@addtoplength[-]{refvpos}{\useplength{behrvskip}}
% Correction for the folding marks
\@addtoplength[-]{tfoldmarkvpos}{\useplength{behrfoldmarkvskip}}
\@addtoplength[-]{bfoldmarkvpos}{\useplength{behrfoldmarkvskip}}

% Commands
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Define command aliasses
\newcommand{\fromname}[1]{\setkomavar{fromname}{#1}}
% Fromaddress automatically defines backaddress
\newcommand{\fromaddress}[1]{\setkomavar{fromaddress}{#1}} % \setkomavar{backaddress}{\tiny#1}}
% \newcommand{\backaddress}[1]{\setkomavar{backaddress}{\tiny#1}}
% In case backaddress is needed separately
% \backaddress set to be ignored, fixed for the institute instead
\newcommand{\backaddress}[1]{} % {\setkomavar{backaddress}{\tiny#1}}
\newcommand{\realbackaddress}[1]{\setkomavar{backaddress}{\tiny#1}}

\setkomavar{backaddressseparator}{ \vrule{} }
\setkomavar{date}{\ISOToday}
\realbackaddress{%
\ifnum\language=\l@english
Max Planck Institute for Informatics\\Campus E1 4\\66123 Saarbr\"ucken\\ GERMANY%
\else
Max-Planck-Institut f\"ur Informatik\\Campus E1 4\\66123 Saarbr\"ucken%
\fi
}%

\newkomavar{fromgroup}
\newcommand{\fromgroup}[1]{\setkomavar{fromgroup}{#1}}
\newcommand{\fromphone}[1]{\setkomavar{fromphone}{#1}}
\newcommand{\fromfax}[1]{\setkomavar{fromfax}{#1}}
\newcommand{\fromemail}[1]{\setkomavar{fromemail}{#1}}
\newkomavar{fromextra}
\newcommand{\fromextra}[1]{\setkomavar{fromextra}{#1}}
\newcommand{\subject}[1]{\setkomavar{subject}{#1}}
\newcommand{\signature}[1]{\setkomavar{signature}{#1}}
% Make signature and closing left aligned
\let\raggedsignature=\raggedright


% Set defaults for variables. User may (shall!) override before \opening{}
% In case the MPI-Inf paper is being used turn off logo and backaddress
\newkomavar{nologo}\setkomavar{nologo}{}
\newcommand{\nologo}{\setkomavar{nologo}{1}\setkomavar{backaddress}{}}

% english and german logo differ in length, concentrate on the height 
\@newplength{logoheight}\@setplength{logoheight}{3.26cm}%



% Headers and footers
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Definitions and concept are strongly influenced
% by the article by Markus Kohm in DTK 02/2003
% all available space for header and footer
% position and size for firsthead
 \@setplength{firstheadvpos}{0pt}
 \@setplength{firstheadwidth}{\paperwidth}
% position and size for firstfoot
 \@setplength{firstfootvpos}{\paperheight}
\@addtoplength[-]{firstfootvpos}{\useplength{toaddrvpos}}
 \@addtoplength[-]{firstfootvpos}{1cm}
 \@addtoplength[-]{firstfootvpos}{2\baselineskip} % thats a lie, actually
% Width of right margin, defined above
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
\setkomavar{firsthead}{%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
% Infocolumn
% move to the right border
\hspace*{\fill}%
% Zero dimension picture for absolute placement :)
% \begin{picture}(0,0)
%   \put(0,0)
{\parbox[t]{\useplength{infocolwidth}}{%
% \vspace{-0.9cm}
    % No \raggedright or similar, because this will produce
    % "There's no line here to end." Error messages.
    % Break lines manually with "\\"
    % Skip to below logo, accomodate 5mm printer margin plus extra
    % \vspace{\useplength{logoheight}}
    % \vspace{7mm}
    \vspace{11.5mm}
    % rather small font, in order to use space efficiently
    \fontsize{8}{9}\selectfont
    
    % \\
    \Ifkomavarempty{nologo}{%
% Das passt mit Logo
\hspace{-8cm}\hspace*{\fill}%
\ifnum\language=\l@english
\includegraphics[height=\useplength{logoheight},]{mpi-inf-print-CMYK.pdf}%
\else
\includegraphics[height=\useplength{logoheight},]{mpi-inf-de-print-CMYK.pdf}%
\fi
\hspace{1.5cm}\vspace{0.7cm} \\}{%
% das passt ohne Logo, mit neuem Logo nicht getestet, dazu braucht man das aktualisierte Papier als Vorlage.
\hspace{-8cm}\hspace*{\fill}\includegraphics*[height=0cm,width=0cm]{mpi-inf.pdf}\vspace{\useplength{logoheight}}\hspace{0.4cm}\vspace{2.3cm} \\}%
    \Ifkomavarempty{fromname}{}{\textbf{\usekomavar{fromname}}\par\vspace{.5\baselineskip}}
    \Ifkomavarempty{fromgroup}{}{\textbf{\usekomavar{fromgroup}}\par\vspace{.5\baselineskip}}
    \Ifkomavarempty{fromaddress}{}{\usekomavar{fromaddress}\par\vspace{.5\baselineskip}}
    \begin{tabular}{@{}l@{}l}
        \Ifkomavarempty{fromphone}{}{\usekomavar*{fromphone}&\quad +49 681 9325\,--\,\usekomavar{fromphone}\\}
        \Ifkomavarempty{fromfax}{}{\usekomavar*{fromfax}&\quad +49 681 9325\,--\,\usekomavar{fromfax}\\}
        \Ifkomavarempty{fromemail}{}{\usekomavar*{fromemail}&\quad \usekomavar[\url]{fromemail}\\}
        % \usekomavar*{fromurl}Web: &\quad \url{www.mpi-inf.mpg.de}\\
              Web: &\quad \url{www.mpi-inf.mpg.de}\\
      \end{tabular}\par\vspace{.5\baselineskip}
      \Ifkomavarempty{fromextra}{}{\usekomavar{fromextra}\par\vspace{.5\baselineskip}}
      % Just in case...
      \rmfamily\normalsize
      \vspace{0.3cm}\usekomavar{date}
%      \vspace{1cm}\ISOToday
%     } %parbox
  } %put
% Position date
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \put(0,0){
%   \parbox[t]{\useplength{infocolwidth}}{%
     \vspace{\useplength{refvpos}}
     \vspace{\useplength{refaftervskip}}
     \ \\[1\baselineskip]
     % Date ist probably never empty, but just in case
     % See also below
%     \Ifkomavarempty{date}{}{\usekomavar{date}}
%   } %parbox
  } %put
% \end{picture}
}



\l@addto@macro\@firstheadfootfield{\setkomavar{date}{\ }}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
\@setplength{firstfootvpos}{\paperheight}
\@addtoplength{firstfootvpos}{-2cm}
\setkomavar{firstfoot}{%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
% rather small font, in order to use space efficiently
\fontsize{8}{9}\selectfont
\parbox[b]{\linewidth}{%
\centering%
% \hspace{2cm}%
% something I actually wanted to avoid
\ifnum\language=\l@english
Directors: %
\else
Direktoren: %
\fi
Prof.~Anja~Feldmann,~Ph.D., 
Prof.~Dr.~Danupon~Nanongkai,
% \hspace{3cm}
Prof.~Dr.~Bernt~Schiele,\\
Prof.~Dr.~Hans-Peter~Seidel,
Prof.~Dr.~Christian~Theobalt,
Prof.~Dr.~Gerhard~Weikum
} %parbox
} %firstfoot


