%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                                              %
% romsaf10.cls                                                                 %
%                                                                              %
% A LaTeX class for ROM SAF documents, v1.0 [2018/06/08]                       %
%                                                                              %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Updated: J. K. Nielsen, DMI [2020/03/30] v1.0
%      - NRT Defintion changed again
%
% Updated: J. K. Nielsen, DMI [2020/02/7] v1.0
%      - DocChange can now be extended to infinity!
%
% Updated: J. K. Nielsen, DMI [2019/12/18] v1.0
%      - multible Prepared By, Reviewed By and Approved By fields allowed
%      - New \VSAuthor command for frontpage
%
% Updated: J. K. Nielsen, DMI [2019/12/10] v1.0
%      - vsreport generates the right frontpage with CDOP-3, VS,
%        report number, author. Normal frontpage reproduced when vsreport is
%        not set
%      - added new fields: distribution list and VSAuthor and VSDuration on p.2
%
% Updated: J. K. Nielsen, DMI [2019/09/26] v1.0
%      - Fixed issue with \it \itshape
%      - KOMA-Script v3.19a or larger is now default.
%
% Updated: J. K. Nielsen, DMI [2019/08/15] v1.0
%      - \bf -> \bfseries
%
% Updated: J. K. Nielsen, DMI [2018/06/10] v1.0
%      - changed frontpage layout
%      - changed doc. author / doc. ch table / record format
%        
% Updated: J. K. Nielsen, DMI [2018/02/05] v1.0 
%      - option 'vsreport' to change frontpage as well as VS specific notes
%        after DCR.
%      - new latex font statements
%      - some changes to the formal ROM SAF stuff 
%      - Jordis' interpenalty bug-fix implemented (no effect on template10)
%    
% Updated: K. B. Lauritsen, DMI [2014/03/12] v1.0
%      - option 'vs' to have both the VS class and Document class as one file
%      - all GRAS SAF text changed to ROM SAF
%      - editorials
%
% Updated: JK Nielsen, DMI [2014/2/26] v0.7
%      - trying to merge Oscars v0.6 changes into .cls that would work on linux
%      - removed "Document" from page header
%      - splitted DCR
%                                                
% Updated: JK Nielsen, DMI [2013/4/4] v0.5 ("extra")
%      - various small adjustments and new ROM SAF format defined by KBL 
%
% Updated: Oscar Isoz, LTU [2012/9/15] v0.6
%      - added VSauthor and VSduration commands
%      - Added VS Author and VS Duration "sections" on the first page
%        after the title page
%      - Modified the front page to match the Word template better
%      - Modfied Approved,Prepared and Reviewed commands to allow
%        a comment to be added
%                                   
% Updated: JK Nielsen, DMI [2012/4/16] v0.5
%      - inclusion of ROM SAF logos
%
% Updated: JK Nielsen, DMI [2011/4/14] v0.4
%      - pdflatex compatible
%      - MSword-like headings
%      - headings on first pages
%      - adopted new KOMA option formats
%      - bibtex plays together with the ``[RD.]'' formatted reference list;
%        needs grassaf04.bst in order to work!
%      - figure-caption forced to pagewith
%
% Updated: S Syndegaard, DMI and H Lewis, Met Office [2009/10/20] v0.3
%      - use of san-serif as font default
%      - some font-size changes on the front-page
%      - inclusion of new GRAS SAF logos.
%               
% Created by C. Marquardt, Met Office, Exeter [2009]
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                                              %
% Below is the descriptions from the original file; it has been updated        %
% to version 1.0 (but may nevertheless not be fully accurate).                 %
%                                                                              %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                                              %
% Options and default settings                                                 %
% ----------------------------                                                 %
%                                                                              %
% This class is derived from the KOMA Script classes. Thus, (nearly) all       %
% options that can be given to any KOMA class can also be given to this        %
% document class.                                                              %
%                                                                              %
% However, some defaults are different to the KOMA Script classes. In          %
% particular, the document will be two sided; to obtain one sided output,      %
% the option                                                                   %
%                                                                              %
%    oneside                                                                   %
%                                                                              %
% must be specified in the \documentclass command. Also, all headings will     %
% will be produced using the smallheadings option of KOMA Script; any other    %
% choice must be requested by giving either the                                %
%                                                                              %
%    bigheadings                                                               %
%                                                                              %
% or                                                                           %
%                                                                              %
%    normalheadings                                                            %
%                                                                              %
% options to the \documentclass command. As with KOMA, the default page        %
% size is A4 (but can be changed with, e.g., the usual ...paper options).      %
%                                                                              %
%                                                                              %
% KOMA base class                                                              %
% ---------------                                                              %
%                                                                              %
% The default base class used by grassaf is the scrreprt document class,       %
% corresponding to the report document class in plain LaTeX. Instead, the      %
% scrartcl and scrbook classes (corresponding to the article and book classes  %
% of standard LaTeX) can be choosen by specifying the options                  %
%                                                                              %
%    article                                                                   %
%                                                                              %
% and                                                                          %
%                                                                              %
%    book                                                                      %
%                                                                              %
% in the \documentclass command, respectively. Note that the grassaf document  %
% class has been developed with a relatively recent version of the KOMA script %
% document classes. Therefore, it is desireable that the most recent versions  %
% of KOMA script are available in the user's TeX / LaTeX installation.         %
%                                                                              %
%                                                                              %
% Additional packages used                                                     %
% ------------------------                                                     %
%                                                                              %
% This class also uses (and therefore requires) the following LaTeX packages:  %
%                                                                              %
%    geometry                                                                  %
%    ifthen                                                                    %
%    calc                                                                      %
%                                                                              %
% Note that, as with the KOMA script classes, it is sensible to make sure      %
% that the most recent version is installed; otherwise, this document class    %
% might not work properly.                                                     %
%                                                                              %
%                                                                              %
% Page layout, headers and footers                                             %
% --------------------------------                                             %
%                                                                              %
% The page layout is constructed using the geometry package, but not with      %
% KOMA's own layout engine. As a consequence, the DIV and BCORR options        %
% available in KOMA have no effect, and should probably not be specified.      %
%                                                                              %
% Note that the size of the text body (including header and footer) is         %
% hardwired in this document class, and cannot be changed. Similarly, the      %
% layout of the headers and footers is not intended to be changed. The         %
% header's content can be set by the following commands provided by the        %
% grassaf class:                                                               %
%                                                                              %
%    \DocTitle{...}         Title, to appear on the title page                 %
%    \DocShortTitle{...}    Short title, to appear in the header               %
%    \DocReference{...}     Reference ID, to appear in the header              %
%    \DocVersion{...}       Document version, to appear in title and header    %
%    \DocDate{...}          Document date, to appear in title and header       %
%                                                                              %
%                                                                              %
% Signature and document change tables                                         %
% ------------------------------------                                         %
%                                                                              %
% Both a Document Signature Table and a Document Change Record table will be   %
% typeset on the backtitle (i.e., the second page immediately after the        %
% title). The entries for the Document Signature Table are defined using       %
% the following three commands:                                                %
%                                                                              %
%    \PreparedBy{<name>}{<function>}{<date>}{<comment>}                        %
%    \ReviewedBy{<name>}{<function>}{<date>}{<comment>}                        %
%    \ApprovedBy{<name>}{<function>}{<date>}{<comment>}                        %
%                                                                              %
% where the mandatory arguments <name> and <function> denote the author(s)     %
% or persons being involved in the relevant task (e.g., A.U. Thor) and their   %
% function (e.g., ROM SAF Project Manager).                                    %
%                                                                              %
% The Document Change Record table is generated through a series of the        %
% command                                                                      %
%                                                                              %
%    \DocChange{<version>}{<date>}{<by>}{<description>}                        %
%                                                                              %
% with the obvious meaning of the mandatory arguments.                         %
% In the case where the DCR exceeds the limits of page 2 one has to split it   %
% manually by using this adhoc command for the excess entries:                 %
%                                                                              %
%    \DocChangeExt{<version>}{<date>}{<by>}{<description>}                     %
%    - and un-comment \DocumentChangeRecordExtra after \maketitle              %
%                                                                              %
%                                                                              %
% Continued figures and tables                                                 %
% ----------------------------                                                 %
%                                                                              %
% When typesetting long tables or including several subfigures into one,       %
% the resulting table or figure may spread out over several pages. The         %
% commands                                                                     %
%                                                                              %
%    \continuedtable                                                           %
%    \continuedfigure                                                          %
%                                                                              %
% placed inside a table or figure environment and before the next \caption     %
% will reduce the table or figure counter and therefore allow the creation     %
% of 'continued' tables or figures. However, the caption text itself must      %
% be manually adapted, e.g. to include a '(cont'd)' at the end of the          %
% caption text.                                                                %
%                                                                              %
% Note that the longtable package provides an alternative for multipage        %
% tables, although these are no longer handled as ordinary floats.             %
%                                                                              %
%                                                                              %
% Example                                                                      %
% -------                                                                      %
%                                                                              %
% The ROPP User Guide contains the following declarations:                     %
%                                                                              %
%    \documentclass{romsaf}                                                    %
%                                                                              %
%       ...                                                                    %
%                                                                              %
%    \DocTitle{The Radio Occultation Processing Package (ROPP)\\               %
%              User Guide}                                                     %
%    \DocAuthor{Me and Him} (optional, default the ROM SAF consortium)         %
%    \DocShortTitle{ROPP User Guide}                                           %
%    \DocReference{SAF/ROM/METO/UG/ROPP/01}                                    %
%    \DocVersion{Version 0.1}                                                  %
%    \DocDate{22 October 2004}                                                 %
%                                                                              %
%       ...                                                                    %
%                                                                              %
%    \PreparedBy{C. Marquardt}{Research Scientist}                             %
%    \PreparedBy{D. Offiler}{ROM SAF Project Team}                             %
%    \ApprovedBy{K. B. Lauritsen}{ROM SAF Project Manager}                     %
%                                                                              %
%       ...                                                                    %
%                                                                              %
%    \DocChange{Version 0.0}{25 Oct 2004}{Him}{Initial structure}              %
%    \DocChange{Version 0.0}{25 Oct 2004}{Him}{Initial structure}              %
%       ...                                                                    %
%    \DocChangeExt{Version 1.0}{29 Oct 2004}{Me}{Initial revision}             %
%                                                                              %
%       ...                                                                    %
%                                                                              %
%    \begin{document}                                                          %
%                                                                              %
%       ...                                                                    %
%                                                                              %
%    \end{document}                                                            %
%                                                                              %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% 1. Formalities
% --------------

\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesClass{romsaf10}[2017/05/02 ROM SAF report class v1.0]
\newcommand{\cut}[1]{}



% new in version 1.0. vsreport option
\newif\if@vsreport\@vsreportfalse
\DeclareOption{vsreport}{\@vsreporttrue}



% 2. Options
% ----------

% KOMA base class

\newif\if@chapters\@chapterstrue
\newcommand*{\komaclass}{scrreprt}
\DeclareOption{article}{\renewcommand{\komaclass}{scrartcl}\@chaptersfalse}
\DeclareOption{book}{\renewcommand{\komaclass}{scrbook}}

% 2.0 Use times-roman as font default.

\renewcommand{\familydefault}{\rmdefault}

% 2.1 Make twoside the default (to be switched with oneside)

\newif\if@twoside\@twosidetrue
\DeclareOption{oneside}{\@twosidefalse}

% 2.2 Make smallheadings the default

\newif\if@bigheadings\@bigheadingsfalse
\newif\if@normalheadings\@normalheadingsfalse
\newif\if@smallheadings\@smallheadingstrue
\DeclareOption{bigheadings}{\@smallheadingsfalse\@bigheadingstrue}
\DeclareOption{normalheadings}{\@smallheadingsfalse\@normalheadingstrue}
\DeclareOption{smallheadings}{\@smallheadingstrue}

% 2.3 Userguide layout option

\newif\if@userguide\@userguidefalse
\DeclareOption{userguide}{\@userguidetrue}

% 2.4 Pass everything else to KOMA

\DeclareOption*{\PassOptionsToClass{\CurrentOption}{\komaclass}}

% 2.5 Other (hardwired) defaults

\PassOptionsToClass{numbers=noenddot,cleardoublepage=current,bibliography=totoc}{\komaclass}

% 2.6 Process options

\ProcessOptions\relax

% 2.7 Set defaults

\if@twoside
   \PassOptionsToPackage{twoside}{geometry}
\fi
\if@smallheadings
   \PassOptionsToClass{headings=small}{\komaclass}
\else
   \if@normalheadings
      \PassOptionsToClass{headings=normal}{\komaclass}
   \fi
\fi

% 2.8 Load the KOMA class

\LoadClass{\komaclass}[2004/01/07]

% 2.9 Page layout package

\if@userguide
   \RequirePackage[total={17cm,27.5cm},heightrounded,includemp,
                   includeheadfoot,head=12mm,headsep=8mm,footskip=11mm,
                   dvips,bindingoffset=12mm]{geometry}
\else
   \RequirePackage[total={17cm,27.5cm},heightrounded,
                   includeheadfoot,head=12mm,headsep=8mm,footskip=11mm,
                   dvips,bindingoffset=12mm]{geometry}
\fi

\setlength{\parskip}{2ex}

% 2.10 Header package

\RequirePackage[manualmark]{scrpage2}
\PassOptionsToPackage{oneside}{scrpage}

% 2.11 Other packages

\RequirePackage{ifthen}
\RequirePackage{calc}
\RequirePackage{graphicx}
\RequirePackage{colortbl}[2001/02/13]

% 3. Define new commands for headers and footers
% ----------------------------------------------

\newcommand\@DocTitle{UNKNOWN}
\newcommand\@DocSubTitle{UNKNOWN}
\newcommand\@DocAuthor{\normalfont \sffamily 
{\normalfont \sffamily  \bfseries ROM SAF Consortium}\\
 Danish Meteorological Institute (DMI)\\
            European Centre for Medium-Range Weather Forecasts (ECMWF)\\ 
            Institut d'Estudis Espacials de Catalunya (IEEC)\\   %%% '-hack
            Met Office (UKMO)}
\newcommand\@DocWriter{UNKNOWN}
\newcommand\@DocShortTitle{UNKNOWN}
\newcommand\@DocReference{UNKNOWN}
\newcommand\@DocVersion{UNKNOWN}
\newcommand\@DocDate{UNKNOWN}

\newcommand\DocTitle[1]{\renewcommand\@DocTitle{#1}}
\newcommand\DocSubTitle[1]{\renewcommand\@DocSubTitle{#1}}
\newcommand\DocAuthor[1]{\renewcommand\@DocAuthor{#1}}
\newcommand\DocWriter[1]{\renewcommand\@DocWriter{#1}}
\newcommand\DocShortTitle[1]{\renewcommand\@DocShortTitle{#1}}
\newcommand\DocReference[1]{\renewcommand\@DocReference{#1}}
\newcommand\DocVersion[1]{\renewcommand\@DocVersion{#1}}
\newcommand\DocDate[1]{\renewcommand\@DocDate{#1}}


% 3.1 Define VS Report specific commands 
\newcommand\@VSAuthor{UNKNOWN}
\newcommand\@VSAuthorText{UNKNOWN}
\newcommand\@VSDurationText{UNKNOWN}
\newcommand\@VSDistributionText{UNKNOWN}
\newcommand\VSAuthorText[1]{\renewcommand\@VSAuthorText{#1}}
\newcommand\VSAuthor[1]{\renewcommand\@VSAuthor{#1}}
\newcommand\VSDurationText[1]{\renewcommand\@VSDurationText{#1}}
\newcommand\VSDistributionText[1]{\renewcommand\@VSDistributionText{#1}}
\newcommand\@VSNumber{**}
\newcommand\VSNumber[1]{\renewcommand\@VSNumber{#1}}
% 4. Define ROM SAF headers and footers
\renewcommand*{\pnumfont}{\normalfont \sffamily }
% --------------------------------------
%
% Note: By defaut, the \chapter command resets the pagestyle to plain,
%       so we have to redefine the \chapterpagestyle.


\setlength{\marginparwidth}{2.8cm}
\setlength{\marginparsep}{0.0cm}
\setlength{\marginparsep}{0.0cm}
\setlength{\hoffset}{-1.0in}

\setlength{\textwidth}{15.5cm}%{16.3cm}
\setlength{\arrayrulewidth}{0.7pt}
%line separation in a tabular double rule
\setlength\doublerulesep{1pt}
\setlength{\oddsidemargin}{2.8cm}
\setlength\evensidemargin{\oddsidemargin}

\newlength{\hfwidth}
\if@userguide
   \setheadwidth[0pt]{textwithmarginpar}
   \setfootwidth[0pt]{textwithmarginpar}
   \setlength{\hfwidth}{\textwidth+\marginparwidth+\marginparsep}
\else
   \setheadwidth[0pt]{\textwidth}
   \setfootwidth[0pt]{text}
   \setlength{\hfwidth}{\textwidth}
\fi

%Probably not used
\renewpagestyle{plain}{(\textwidth,0.0pt)% header line
{\hfill}%
{\hfill}%
{\hfill}%
(\textwidth,0.0pt)}%
{(\textwidth,0.0pt)% footer line
{\hfill}%
{\hfill}%
{\hfill}%
(\textwidth,0pt)}



\newcommand{\grassheader}
{
 \renewcommand{\familydefault}{\sfdefault}

\vspace{0cm}\hspace{-2.2mm}
 \begin{tabularx}{\hfwidth}{|p{50.33mm}|p{50.33mm}|X|}
    \hline
    \parbox[p][][c]{0.33\hfwidth}%
           {\fontsize{9pt}{10pt}\selectfont\normalfont\raggedright
             \vspace{1mm} 
                 Ref: \@DocReference\\
             Version: \@DocVersion\\
             Date: \@DocDate\\
 %            Doc: \formattedjobname\\
             \vspace{1mm} 
           } &%
    \parbox[p][][c]{0.33\hfwidth}%
             {\fontsize{10pt}{11pt}\selectfont\normalfont\centering%
               \vspace{1mm}
               \if@vsreport
               ROM SAF CDOP-3\\
               Visiting Scientist Report \@VSNumber
               \else
               \@DocShortTitle\\
               \fi
               \vspace{1mm} 
             }&%
    \parbox[p][12mm][c]{0.33\hfwidth}{\includegraphics[width=38mm]{ROMSAF_noName_Colour}}\\
    \hline
  \end{tabularx}
}%



\renewpagestyle{headings}{(\textwidth,0.0pt)% header
{\grassheader}%
{\grassheader}%
{\grassheader}%
(\textwidth,0.0pt)}%
{(\textwidth,0.0pt)% footer
{\normalfont \sffamily  \hfill\pagemark\  of \pageref{LastPage}\hfill}%
{\normalfont \sffamily  \hfill\pagemark\ of \pageref{LastPage}\hfill}%
{\normalfont \sffamily  \hfill\pagemark\  of \pageref{LastPage}\hfill}%{\hfill\pagemark\hfill}%
(\textwidth,0pt)}




% new in version 1.0:
% print in the lower left corner on the frontpage:

\if@vsreport
  \renewpagestyle{empty}{(\textwidth,0.0pt)% header
  {}%
  {}%
  {}%
  (\textwidth,0.0pt)}%
  {(\textwidth,0.0pt)% footer
  {\hfill  \pagemark\ \normalfont \sffamily  of \pageref{LastPage}\hfill}%
  {\fontsize{10pt}{11pt} \raisebox{-0.5cm}{\parbox{6cm}
  {\normalfont \sffamily  Ref: \@DocReference \\  
  Version: \@DocVersion\\
  Date: \@DocDate\\}}\hfill}%
  {\hfill  \pagemark\ \normalfont \sffamily  of \pageref{LastPage} \hfill}%
  (\textwidth,0pt)}
  \renewcommand{\titlepagestyle}{empty}
\else
  \renewpagestyle{empty}{(\textwidth,0.0pt)% header
  {}%
  {}%
  {}%
  (\textwidth,0.0pt)}%
  {(\textwidth,0.0pt)% footer
  {\hfill  \pagemark\ \normalfont \sffamily  of \pageref{LastPage}\hfill}%
  {\fontsize{10pt}{11pt} \raisebox{-0.5cm}{\parbox{6cm}
  {\normalfont \sffamily  Ref: \@DocReference}}\hfill}%
  {\hfill  \pagemark\ \normalfont \sffamily  of \pageref{LastPage} \hfill}%
  (\textwidth,0pt)}
  \renewcommand{\titlepagestyle}{empty}
\fi


\if@chapters
   \renewcommand*{\chapterpagestyle}{headings}
\fi
  

% Redefine the empty page style (for the title page):
\cut{
\deftripstyle{empty}{}{}{}
   {\fontsize{10pt}{11pt}\selectfont\normalfont Ref: \@DocReference}{}{}%
}

\pagestyle{headings} 


% 5. Title page
% -------------

\titlehead{ }
 \if@vsreport
  \subject{\vspace{-0.5cm}\includegraphics[width=0.85\textwidth]{ROMSAF_Name_Colour}\vspace{1.4cm}}
%%% for VS24 
%
\title{{\fontsize{24pt}{24pt}\selectfont\bfseries ROM SAF CDOP-3} \\[1cm]
{\fontsize{24pt}{24pt}  \selectfont\bfseries Visiting Scientist Report \@VSNumber:} \\[1cm]
\fontsize{17pt}{17pt}\selectfont\bfseries\@DocTitle \\}
\author{\fontsize{17pt}{17pt}\selectfont\bfseries}
\date{\normalfont \sffamily\fontsize{17pt}{17pt}\selectfont\bfseries\@VSAuthor\\}

\publishers{\vspace{1.5cm}\normalfont \sffamily \fontsize{13pt}{13pt}\selectfont \@DocAuthor\\}

\else

\subject{\vspace{-3.0cm}\includegraphics[width=1.0\textwidth]{ROMSAF_Name_Colour}\vspace{1.4cm}}
\title{      {\fontsize{24pt}{24pt}  \selectfont\bfseries \@DocTitle}}
\author{\normalfont \sffamily \LARGE\fontsize{17pt}{17pt}\selectfont\bfseries Version \@DocVersion}
\date{\normalfont \sffamily \LARGE\fontsize{17pt}{17pt}\selectfont\bfseries \@DocDate\\[1cm] \ }
\publishers{\vspace{1.5cm}\normalfont \sffamily \LARGE\fontsize{13pt}{13pt}\selectfont \@DocAuthor\\}
\fi
%Back to Times Roman
\renewcommand{\familydefault}{\rmdefault}
% 6. The backtitle
% ----------------

% 6.1 A strut for the tables

\newlength\lstrutlength
\setlength{\lstrutlength}{\baselineskip/\baselinestretch}
\addtolength{\lstrutlength}{1.5mm}
\newcommand\lstrut{\rule[-2mm]{0mm}{\lstrutlength}}

% 6.2 Document Author Table commands

\newcommand\@PreparedBy{UNKNOWN}
\newcommand\@ReviewedBy{UNKNOWN}
\newcommand\@ApprovedBy{UNKNOWN}
\newcommand\@PreparedFunc{UNKNOWN}
\newcommand\@ReviewedFunc{UNKNOWN}
\newcommand\@ApprovedFunc{UNKNOWN}
\newcommand\@PreparedDate{UNKNOWN}
\newcommand\@ReviewedDate{UNKNOWN}
\newcommand\@ApprovedDate{UNKNOWN}
\newcommand\@PreparedComment{UNKNOWN}
\newcommand\@ReviewedComment{UNKNOWN}
\newcommand\@ApprovedComment{UNKNOWN}

\newcounter{PBc}\setcounter{PBc}{0}
\newcommand\PBc@rows{}
\newcommand\PreparedBy[4]{%
  \addtocounter{PBc}{1}
  \@temptokena=\expandafter{\PBc@rows}
  \xdef\PBc@rows{\the\@temptokena
{Prepared by:} &
#1\noexpand\lstrut\protect & 
#2\protect &
#3\protect
\tabularnewline
\noexpand\hline}
}

\newcounter{RBc}\setcounter{RBc}{0}
\newcommand\RBc@rows{}
\newcommand\ReviewedBy[4]{%
  \addtocounter{RBc}{1}
  \@temptokena=\expandafter{\RBc@rows}
  \xdef\RBc@rows{\the\@temptokena
    {Reviewed by (Internal):}\noexpand\lstrut\protect&
    {#1\protect}&
    {#2\protect}&
    {#3\protect}
    \tabularnewline
    \noexpand\hline}
}

\newcounter{ABc}\setcounter{ABc}{0}
\newcommand\ABc@rows{}
\newcommand\ApprovedBy[4]{%
  \addtocounter{ABc}{1}
  \@temptokena=\expandafter{\ABc@rows}
  \xdef\ABc@rows{\the\@temptokena
    {Approved by:} &
    #1\noexpand\lstrut\protect & 
    #2\protect &
    #3\protect
    \tabularnewline
    \noexpand\hline}
}


% 6.3 Document Change Record commands

\newcounter{dcc}\setcounter{dcc}{0}
\newcommand\DC@rows{}
\newcommand\DocChange[4]{%
              \addtocounter{dcc}{1}
              \@temptokena=\expandafter{\DC@rows}
              \xdef\DC@rows{\the\@temptokena 
#1\noexpand\lstrut\protect & 
#2\protect &
#3\protect & 
#4\protect
\tabularnewline
          \noexpand\hline}
           }

\newcounter{dccExt}\setcounter{dccExt}{0}
\newcommand\DCExt@rows{}
\newcommand\DocChangeExt[4]{%
              \addtocounter{dccExt}{1}
              \@temptokena=\expandafter{\DCExt@rows}
              \xdef\DCExt@rows{\the\@temptokena 
#1\noexpand\lstrut\protect & 
#2\protect &
#3\protect & 
#4\protect
\tabularnewline
          \noexpand\hline}
           }

% 6.3 The tables

\newcommand{\DocumentAuthorTable}{ 
\parbox{\textwidth}{\fontsize{10pt}{10pt}\normalfont \sffamily 
\begin{center}
\vspace*{1cm}
\begin{tabularx}{\textwidth}[c]
{|l|X|l|c|}
\doublerulesepcolor[gray]{0.95}
\hline
\hline
\multicolumn{4}{>{\cellcolor[gray]{0.95}}l}{
 \parbox{150mm}{\raggedright\vspace{1mm}{\fontsize{12pt}{12pt}\normalfont \sffamily 
  \bfseries  DOCUMENT AUTHOR TABLE \hfill} \vspace{1mm}}}\\
\hline
\hline
\multicolumn{4}{c}{}\\
\hline
       \multicolumn{1}{|>{\cellcolor[gray]{0.95}}c|}{\parbox{.1\textwidth}{\raggedright\vspace{1mm}\fontsize{12pt}{12pt}\selectfont\sffamily\normalcolor\bfseries\emph{ }\vspace{1mm}}} & 
       \multicolumn{1}{>{\cellcolor[gray]{0.95}}c|}{\parbox{.1\textwidth}{\centering\vspace{1mm}\fontsize{12pt}{12pt}\selectfont\sffamily\normalcolor\bfseries\emph{Author(s)}\vspace{1mm}}} & 
       \multicolumn{1}{>{\cellcolor[gray]{0.95}}c|}{\parbox{.1\textwidth}{\centering\vspace{1mm}\fontsize{12pt}{12pt}\selectfont\sffamily\normalcolor\bfseries\emph{Function}\vspace{1mm}}} &
       \multicolumn{1}{>{\cellcolor[gray]{0.95}}c|}{\parbox{.1\textwidth}{\centering\vspace{1mm}\fontsize{12pt}{12pt}\selectfont\sffamily\normalcolor\bfseries\emph{Date}\vspace{1mm}}} \\%& 
       \hline
       \ifnum 0=\value{PBc}
       \lstrut & & \\
       \else
       \PBc@rows
       \fi
       %
       \ifnum 0=\value{RBc}
       \lstrut & & \\
       \else
       \RBc@rows
       \fi
       %
       \ifnum 0=\value{ABc}
       \lstrut & & \\
       \else
       \ABc@rows
       \fi
\end{tabularx}
\end{center}
}
}


\uppertitleback{

\chapter*{}
\addcontentsline{toc}{chapter}{Document Change Record}
\vspace{-2.3cm}
\DocumentAuthorTable
\DocumentChangeRecord
\if@vsreport
\documentDistributionList
\romsafVisitingScientist
\fi
}



%6.4 Document Change Record
 
\newcommand{\DocumentChangeRecord}{\renewcommand{\familydefault}{\sfdefault}\selectfont
  \parbox{\textwidth}{\fontsize{10pt}{10pt}\normalfont \sffamily 
    \vspace{1cm}
    \begin{tabularx}{\textwidth}[c]{|c|l|c|X|}
      \hline
      \hline
      \multicolumn{4}{>{\cellcolor[gray]{0.95}}l}{
        \parbox{100mm}{\raggedright\vspace{1mm}{\fontsize{12pt}{12pt}\normalfont \sffamily  \normalfont \bfseries  DOCUMENT CHANGE RECORD \hfill}\vspace{1mm}}} \\
      \hline
      \hline
      \multicolumn{4}{l}{}\\ 
      \hline
      \multicolumn{1}{|>{\cellcolor[gray]{0.95}}c|}{\parbox{30mm}{\centering\vspace{1mm}\fontsize{12pt}{12pt}\normalfont \sffamily \bfseries\emph{Version}\vspace{0.7mm}}} & 
      \multicolumn{1}{>{\cellcolor[gray]{0.95}}c|}{\parbox{20mm}{\centering\vspace{1mm}\fontsize{12pt}{12pt}\normalfont \sffamily \bfseries\emph{Date}\vspace{0.7mm}}} & 
      \multicolumn{1}{>{\cellcolor[gray]{0.95}}c|}{\parbox{20mm}{\centering\vspace{1mm}\fontsize{12pt}{12pt}\normalfont \sffamily \bfseries\emph{By}\vspace{0.0mm}}} &
      \multicolumn{1}{>{\cellcolor[gray]{0.95}}c|}{\parbox{30mm}{\centering\vspace{1mm}\fontsize{12pt}{12pt}\normalfont \sffamily \bfseries\emph{Description}\vspace{0.0mm}}} \\
      \hline
      \ifnum 0=\value{dcc}
      \lstrut & & \\
      \else
      \DC@rows
      \fi
    \end{tabularx}
  }
}

\newlength\nettowidth
\setlength{\nettowidth}{\textwidth-8\tabcolsep-5\arrayrulewidth}

\newcommand{\DocumentChangeRecordExtra}{
  {\renewcommand{\familydefault}{\sfdefault}\selectfont
  \fontsize{10pt}{10pt}\normalfont \sffamily 
  \begin{longtable}
    {|m{0.225\nettowidth}|m{0.16\nettowidth}|m{0.155\nettowidth}|m{0.46\nettowidth}|}
    \hhline{====}
    \multicolumn{4}{>{\cellcolor[gray]{0.95}}l}{
      \parbox{\textwidth-2\tabcolsep+0.5\arrayrulewidth}{\raggedright\vspace{1mm}{\fontsize{12pt}{12pt}\normalfont \sffamily  \normalfont \bfseries  DOCUMENT CHANGE RECORD \hfill} {\normalfont \itshape ... continued }\vspace{1mm}}} \\
    \hhline{====}
    \multicolumn{4}{c}{}\\ 
    \hline
    \multicolumn{1}{|>{\cellcolor[gray]{0.95}}c|}{\parbox{10mm}{\raggedright\vspace{1mm}\fontsize{12pt}{12pt}\normalfont \sffamily \bfseries\emph{Version}\vspace{0.7mm}}} & 
    \multicolumn{1}{>{\cellcolor[gray]{0.95}}c|}{\parbox{20mm}{\raggedright\vspace{1mm}\fontsize{12pt}{12pt}\normalfont \sffamily \bfseries\emph{Date}\vspace{0.7mm}}} & 
    \multicolumn{1}{>{\cellcolor[gray]{0.95}}c|}{\parbox{10mm}{\raggedright\vspace{1mm}\fontsize{12pt}{12pt}\normalfont \sffamily \bfseries\emph{By}\vspace{0mm}}} &
    \multicolumn{1}{>{\cellcolor[gray]{0.95}}c|}{\parbox{30mm}{\raggedright\vspace{1mm}\fontsize{12pt}{12pt}\normalfont \sffamily \bfseries\emph{Description}\vspace{0mm}}} \\
    \hline
    \endfirsthead
    \hhline{====}
    \multicolumn{4}{>{\cellcolor[gray]{0.95}}l}{
      \parbox{\textwidth-2\tabcolsep+0.5\arrayrulewidth}{\raggedright\vspace{1mm}{\fontsize{12pt}{12pt}\normalfont \sffamily  \normalfont \bfseries  DOCUMENT CHANGE RECORD \hfill {\normalfont \itshape ... continued}}\vspace{1mm}}} \\
    \hhline{====}
    \multicolumn{4}{c}{}\\ 
    \hline
    \multicolumn{1}{|>{\cellcolor[gray]{0.95}}c|}{\parbox{10mm}{\raggedright\vspace{1mm}\fontsize{12pt}{12pt}\normalfont \sffamily \bfseries\emph{Version}\vspace{0.7mm}}} & 
    \multicolumn{1}{>{\cellcolor[gray]{0.95}}c|}{\parbox{20mm}{\raggedright\vspace{1mm}\fontsize{12pt}{12pt}\normalfont \sffamily \bfseries\emph{Date}\vspace{0.7mm}}} & 
    \multicolumn{1}{>{\cellcolor[gray]{0.95}}c|}{\parbox{10mm}{\raggedright\vspace{1mm}\fontsize{12pt}{12pt}\normalfont \sffamily \bfseries\emph{By}\vspace{0mm}}} &
    \multicolumn{1}{>{\cellcolor[gray]{0.95}}c|}{\parbox{30mm}{\raggedright\vspace{1mm}\fontsize{12pt}{12pt}\normalfont \sffamily \bfseries\emph{Description}\vspace{0mm}}} \\
    \hline
    \endhead
    \hline \multicolumn{4}{r}{\textit{\ }} \\
    \endfoot
    \endlastfoot
    \ifnum 0=\value{dccExt}
    \lstrut & & \\
    \else
    \DCExt@rows
    \fi
  \end{longtable}
}
}

\renewcommand{\theequation}{{\normalfont\rmfamily\thechapter .\arabic{equation}}}

\newcommand{\documentDistributionList}{
\parbox{\textwidth}{\fontsize{10pt}{10pt}\normalfont \sffamily 
\vspace{1cm}
\begin{tabularx}{\textwidth}[l]{X}
  \hline
  \hline
  \cellcolor[gray]{0.95}
  \parbox{100mm}{\vspace{1mm}
          {\fontsize{12pt}{12pt}\normalfont \sffamily  \bfseries  DOCUMENT DISTRIBUTION LIST}
           \vspace{1mm}}\\
         \hline
         \hline
\end{tabularx}}
\fontsize{12pt}{12pt}\rmfamily
\vspace{5mm} \raggedright

\@VSDistributionText}

\newcommand{\romsafVisitingScientist}{
\parbox{\textwidth}{\fontsize{10pt}{10pt}\normalfont \sffamily 
\vspace{1cm}
\begin{tabularx}{\textwidth}[l]{X}
  \hline
  \hline
  \cellcolor[gray]{0.95}
  \parbox{100mm}{\vspace{1mm}
          {\fontsize{12pt}{12pt}\normalfont \sffamily  \bfseries  VS AUTHOR AND DURATION}
           \vspace{1mm}}\\
         \hline
         \hline
\end{tabularx}}
\fontsize{12pt}{12pt}\rmfamily
\raggedright
\fontsize{12pt}{12pt}\rmfamily
\vspace{7mm}\\
\textbf{VS Authors}\\
\@VSAuthorText
\vspace{7mm} \\
\textbf{VS Duration}\\
\@VSDurationText\\}


\newcommand{\romsafText}
{%\renewcommand{\familydefault}{\rmdefault}
%\selectfont \fontsize{12pt}{12pt}
{\normalfont\sffamily\normalcolor\bfseries \bfseries  ROM SAF}\\ 
The Radio Occultation Meteorology Satellite
Application Facility (ROM SAF) is a decentralised processing centre
under EUMETSAT which is responsible for operational processing of
radio occultation (RO) data from the Metop and Metop-SG satellites and radio
occultation data from other missions. The ROM SAF delivers bending
angle, refractivity, temperature, pressure, humidity, and other
geophysical variables in near real-time for NWP users, as well as
reprocessed Climate Data Records (CDRs) and Interim Climate Data
Records (ICDRs) for users requiring a higher degree of homogeneity 
of the RO data sets. The CDRs and ICDRs are further processed into globally
gridded monthly-mean data for use in climate monitoring and climate
science applications.

The ROM SAF also maintains the Radio Occultation Processing Package
(ROPP) which contains software modules that aid users wishing to
process, quality-control and assimilate radio occultation data from
any radio occultation mission into NWP and other models.

The ROM SAF Leading Entity is the Danish Meteorological Institute
(DMI), with Cooperating Entities: i) European Centre for Medium-Range
Weather Forecasts (ECMWF) in Reading, United Kingdom, ii) Institut
D'Estudis Espacials de Catalunya (IEEC) in Barcelona, Spain, and iii)
Met Office in Exeter, United Kingdom. To get access to our products or
to read more about the ROM SAF please go to: \url{http://www.romsaf.org}.}


\newcommand{\romsafIPR}{ 
%\renewcommand{\familydefault}{\rmdefault}
%\selectfont \fontsize{12pt}{12pt}

{\normalfont\sffamily\normalcolor\bfseries  Intellectual Property Rights}\\
All intellectual property rights of the ROM SAF products belong to
EUMETSAT. The use of these products is granted to every interested
user, free of charge. If you wish to use these products, EUMETSAT's
copyright credit must be shown by displaying the words ``copyright
(year) EUMETSAT'' on each of the products used.
}


\newcommand{\romsafDefinitions} {
  
RO data products from the Metop and Metop-SG satellites and RO data from other missions are grouped in \emph{data levels} (Level 0, 1, 2, or 3)
and \emph{product types} (NRT, offline, CDR, or ICDR). The data levels and
product types are defined below\footnote{Note that the level definitions differ partly from the WMO definitions:
\url{http://www.wmo.int/pages/prog/sat/dataandproducts_en.php}}. The lists of variables should not be
considered as the complete contents of a given data level, and not all
data may be contained in a given data level.


{Data levels:\nopagebreak
\begin{itemize}
\setlength\itemsep{-1pt}
\item[]\underline{Level 0}:
Raw sounding, tracking and ancillary data, and other GNSS data before clock correction and reconstruction;

\item[]\underline{Level 1A}: Reconstructed full resolution excess phases, total phases, pseudo ranges, SNRs, orbit information, I, Q values, NCO (carrier) phases, navigation bits, and quality information;

\item[]\underline{Level 1B}: Bending angles and impact parameters, tangent point location, and quality information;

\item[]\underline{Level 2}: Refractivity, geopotential height, ``dry'' temperature profiles (Level 2A), pressure, temperature, specific humidity profiles (Level 2B), surface pressure, tropopause height, planetary boundary layer height (Level 2C), ECMWF model level coefficients (Level 2D), quality information;

\item[]\underline{Level 3}: Gridded or resampled data, that are processed from Level 1 or 2 data, and that are provided as, e.g., daily, monthly, or seasonal means on a spatiotemporal grid, including metadata, uncertainties and quality information.
\end{itemize}}

Product types:\nopagebreak
\begin{itemize}
\setlength\itemsep{-1pt}
\item[]\underline{NRT product}: Data product delivered less than: (i) 3 hours after measurement (ROM SAF Level 2 for EPS); (ii) 150 min after measurement (ROM SAF  Level 2 for EPS-SG Global Mission); (iii) 125 min after measurement (ROM SAF Level 2 for EPS-SG Regional Mission);

 
  
\item[]\underline{Offline product}: Data product delivered from less than 5 days to up to 6 months after measurement, depending on the requirements. The evolution of this type of product is driven by new scientific developments and subsequent product upgrades;

\item[]\underline{CDR}: Climate Data Record generated from a dedicated reprocessing activity using a fixed set of processing software\footnote{(i) GCOS 2016 Implementation Plan; (ii) \url{http://climatemonitoring.info/home/terminology}}. The data record covers an extended time period of several years (with a fixed end point) and constitutes a homogeneous data record appropriate for climate usage;

\item[]\underline{ICDR}: An Interim Climate Data Record (ICDR) regularly extends in time a (Fundamental or Thematic) CDR using a system having optimum consistency with and lower latency than the system used to generate the CDR\footnote{\url{http://climatemonitoring.info/home/terminology} (the ICDR definition was endorsed at the \href{http://ceos.org/meetings/wgclimate-9}{9th session of the joint CEOS/CGMS Working Group Climate Meeting on 29 March 2018}).}.
\end{itemize}
}



% 7. Switch to userguide layout and back
% --------------------------------------

\newcommand*{\userguidelayout}{%
  \changetext{}%
             {-\marginparwidth-\marginparsep}%
             {}%
             {}%
             {}%
 }
\newcommand*{\standardlayout}{\changetext{}{\marginparwidth+\marginparsep}{}{}{}}
\pagestyle{headings} 


% 8. Margin texts
% ---------------

\newcommand{\margintext}[1]{\mbox{}\marginpar{\raggedleft\small\hspace{0pt\emph{\color{cyan}#1}}}}


% 9. Continued figures and tables
% -------------------------------

\providecommand{\continuedtable}{\addtocounter{table}{-1}}
\providecommand{\continuedfigure}{\addtocounter{figure}{-1}}

%\setcapmargin[margin left ]{margin }
%\setcapmargin*[margin inside ]{margin }


% 10. More changes to the default behaviour
% -----------------------------------------

\frenchspacing
\setkomafont{chapter}{\normalfont\sffamily\normalcolor\bfseries\fontsize{18pt}{18pt}\selectfont}
\setkomafont{sectioning}{\sffamily\normalcolor\bfseries}
\setkomafont{caption}{\rmfamily\itshape}
\setkomafont{captionlabel}{\bfseries\usekomafont{caption}}
\newlength{\captionwidth}
\setlength{\captionwidth}{\hsize}
\setlength{\parindent}{0mm}
\setcapwidth[c]{\textwidth}
\setcapindent{0pt}

 

% Chapters, sections, subsections.
%---------------------------------
%\patchcmd{\chapter}{ \vspace*{-0.5cm}}{}{}{}

% If you work on KOMA-Script before v3.19a you must use  this:
%\renewcommand{\chapterheadstartvskip}{\vspace*{-1.4\baselineskip}}
%\renewcommand{\chapterheadendvskip}{\vspace*{0.1\baselineskip}}

% If you work on KOMA-Script v3.19a or later you must use this:
\renewcommand{\chapterheadstartvskip}{}
\renewcommand{\chapterheadendvskip}{}


\renewcommand{\section}{\@startsection
{section}%                   % the name
{1}%                         % the level
{0mm}%                       % the indent
%{0.6\baselineskip     \interlinepenalty\@M}%            % the before skip
{0.6\baselineskip}%            % the before skip
{0.1\baselineskip}%          % the after skip
{\fontsize{14pt}{14pt}\normalfont \sffamily \bfseries }} % the style

\renewcommand{\subsection}{\@startsection
{subsection}%                   % the name
{2}%                         % the level
{0mm}%                       % the indent
{0.1\baselineskip}%            % the before skip
{0.1\baselineskip}%          % the after skip
{\fontsize{12pt}{12pt}\normalfont \sffamily \bfseries }} % the style

\renewcommand{\familydefault}{\rmdefault}


