% Layout and Pagraph Format for Unified Process Methodology
%
% Copyright (c) 2006-2009 Stephane GALLAND <galland@arakhne.org>
% 
% This program is free library; you can redistribute it and/or modify
% it under the terms of the GNU Lesser General Public License as
% published by the Free Software Foundation; either version 3 of the
% License, or any later version.
%
% This library is distributed in the hope that it will be useful, but
% WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
% Lesser General Public License for more details.
%
% You should have received a copy of the GNU Lesser General Public
% License along with this library; see the file COPYING.  If not,
% write to the Free Software Foundation, Inc., 59 Temple Place - Suite
% 330, Boston, MA 02111-1307, USA.
%
% Creation date: 2006-04-06
% Modifications:
%   2009-04-29   Include package pifont (texlive distribution)
%   2007-07-07   Override the bibliography functions.
%   2007-07-06   Bug fix: use varioref for the footnote references.
%   2007-07-05   Add people name formatting function.
%   2007-07-02   Add exponent/indice commands and st/nd/rd/th symbols.
%   2007-06-27   Add inline enumeration.
%   2007-03-19   Add date fonctions.
%                Add localization.
%   2006-04-19   Add version number.
%                Add mtabular and mtable.
%   2006-04-20   Bug fix: invalid position of the tables.
%                Bug fix: centering table's headers.
%

\global\edef\upm@package@fmt@ver{2009/04/29}

\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesPackage{upmethodology-fmt}[\upm@package@fmt@ver]

\gdef\upm@fmt@force@single@spacing#1{{\begin{singlespace}#1\end{singlespace}}}
\gdef\upm@date@head#1/#2\@nil{#1}
\gdef\upm@date@tail#1/#2\@nil{#2}
\gdef\upm@date@first#1{{\expandafter\upm@date@head#1\expandafter\@nil}}
\gdef\upm@date@second#1{{\expandafter\expandafter\expandafter\upm@date@head\expandafter\upm@date@tail#1\expandafter\@nil\expandafter\expandafter\expandafter\@nil}}
\gdef\upm@date@third#1{{\expandafter\expandafter\expandafter\upm@date@tail\expandafter\upm@date@tail#1\expandafter\@nil\expandafter\expandafter\expandafter\@nil}}

%----------------------------------------
% LOCALES
%----------------------------------------
\def\upm@format@lang@english{%
  \gdef\upm@lang@@{\message{**** upmethodology-fmt is using English language ****}}%
  \global\renewcommand{\upm@format@lang@makedate}[3]{##3\string/\two@digits{##2}\string/\two@digits{##1}}%
  \global\let\upm@format@lang@extractyear\upm@date@first%
  \global\let\upm@format@lang@extractmonth\upm@date@second%
}
  \global\let\upm@format@lang@extractyear\upm@date@first%
\def\upm@format@lang@french{%
  \gdef\upm@lang@@{\message{**** upmethodology-fmt is using French language ****}}%
  \global\renewcommand{\upm@format@lang@makedate}[3]{\two@digits{##1}\string/\two@digits{##2}\string/##3}%
  \global\let\upm@format@lang@extractyear\upm@date@third%
  \global\let\upm@format@lang@extractmonth\upm@date@second%
  \global\let\upm@format@lang@extractday\upm@date@first%
}
\global\providecommand{\upm@format@lang@makedate}[3]{}%

%----------------------------------------
% OPTIONS
%----------------------------------------
\DeclareOption{french}{%
  \upm@format@lang@french
  \PassOptionsToPackage{french}{varioref}
}
\DeclareOption{francais}{%
  \upm@format@lang@french
  \PassOptionsToPackage{french}{varioref}
}
\DeclareOption{english}{%
  \upm@format@lang@english
  \PassOptionsToPackage{english}{varioref}
}
\ExecuteOptions{english}
\ProcessOptions
\upm@lang@@


\RequirePackage{xspace}
\RequirePackage{ifthen}
\RequirePackage{graphicx}
\RequirePackage{subfigure}
\RequirePackage{tabularx}
\RequirePackage{multicol}
\RequirePackage{colortbl}
\RequirePackage{picinpar}
\RequirePackage{amsmath}
\RequirePackage{pifont}
\RequirePackage{setspace}
\RequirePackage{varioref}

%----------------------------------------
% Exponent and indice
%----------------------------------------
% Exponent
\newcommand{\textsup}[1]{\ensuremath{^{\text{#1}}}\xspace}
% Indice
\newcommand{\textsub}[1]{\ensuremath{_{\text{#1}}}\xspace}

%----------------------------------------
% SYMBOLS
%----------------------------------------
\let\upm@format@copyright\copyright
\renewcommand{\copyright}{\upm@format@copyright\xspace}
\newcommand{\trademark}{\Pisymbol{psy}{228}\xspace}
\newcommand{\regmark}{\Pisymbol{psy}{226}\xspace}
\newcommand{\smalltrade}{{\tiny\trademark}\xspace}
\newcommand{\smallreg}{{\tiny\regmark}\xspace}
\newcommand{\smallcopy}{{\tiny\copyright}\xspace}
\gdef\st{\textsup{st}}
\gdef\nd{\textsup{nd}}
\gdef\rd{\textsup{rd}}
\gdef\th{\textsup{th}}


%----------------------------------------
% FIGURES
%----------------------------------------

\newcommand{\upm@mfigure}[5][ht]{
	\begin{figure}[#1]%
		\begin{center}%
			\includegraphics[#2]{#3}%
			\caption{#4}%
			\label{fig:#5}%
		\end{center}%
	\end{figure}%
}
\newcommand{\upm@mfigurestar}[5][ht]{
	\begin{figure*}[#1]%
		\begin{center}%
			\includegraphics[#2]{#3}%
			\caption{#4}%
			\label{fig:#5}%
		\end{center}%
	\end{figure*}%
}
%-----
%\mfigure[position]{options}{filename}{caption}{label}
\def\mfigure{\@ifstar\upm@mfigurestar\upm@mfigure}
%-----
%\figref{label}
\newcommand{\figref}[1]{\ref{fig:#1}}
%-----
%\figpageref{label}
\newcommand{\figpageref}[1]{\pageref{fig:#1}}

%-----
% Multi-figures

\newcounter{upm@subfigure@count}

\newcommand{\upm@beginsubfigure}[4]{
	\let\upm@mfiguresaved\mfigure
	%options,filename,caption,label
	\renewcommand{\mfigure}[5][]{
		\xdef\upm@tmp@subfigure@label{\alph{upm@subfigure@count}}%
                \subfigure[##4]{%
			\includegraphics[##2]{##3}%
			\label{fig:##5}%
			\label{fig:#4:\upm@tmp@subfigure@label}%
		}%
		\addtocounter{upm@subfigure@count}{1}%
	}
	%options,filename,caption
	\newcommand{\msubfigure}[3]{
		\xdef\upm@tmp@subfigure@label{\alph{upm@subfigure@count}}%
                \subfigure[##3]{%
			\includegraphics[##1]{##2}%
			\label{fig:#4:\upm@tmp@subfigure@label}%
		}%
		\addtocounter{upm@subfigure@count}{1}%
	}
	\setcounter{upm@subfigure@count}{1}
	\gdef\upm@mfigurescaption{#3}%
	\gdef\upm@mfigureslabel{fig:#4}%
	\begin{#1}[#2]\centering %
}

\newcommand{\upm@endsubfigure}[1]{
		\caption{\upm@mfigurescaption}%
		\label{\upm@mfigureslabel}%
	\end{#1}%
	\let\mfigure\upm@mfiguresaved
}

%-----
%\mfigures[position]{caption}{label}
\newenvironment{mfigures}[3][ht]{
	\upm@beginsubfigure{figure}{#1}{#2}{#3}%
}{%
	\upm@endsubfigure{figure}%
}
%-----
%\mfigures*[position]{caption}{label}
\newenvironment{mfigures*}[3][ht]{
	\upm@beginsubfigure{figure*}{#1}{#2}{#3}%
}{%
	\upm@endsubfigure{figure*}%
}

%----------------------------------------
% IMAGES INCLUDING TeX EXPRESSIONS
%----------------------------------------

\gdef\upm@figtex@remove@width@param#1{#1}
\gdef\upm@figtex@dyncaption@remove{}
\gdef\upm@figtex@figremove#1{%
	\global\expandafter\let\csname FIG#1\endcsname\relax%
}
\gdef\upm@figtex@restore{%
	\upm@figtex@dyncaption@remove%
	\gdef\upm@figtex@dyncaption@remove{}
}
%-----
%\figmath{id}{content}
\def\figmath#1#2{%
	\expandafter\gdef\csname FIG#1\endcsname{\ensuremath{#2}}%
	\global\protected@edef\upm@figtex@dyncaption@remove{\upm@figtex@dyncaption@remove\protect\upm@figtex@figremove{#1}}%
}
%-----
%\figtext{id}{content}
\def\figtext#1#2{%
	\expandafter\gdef\csname FIG#1\endcsname{#2}%
	\global\protected@edef\upm@figtex@dyncaption@remove{\upm@figtex@dyncaption@remove\protect\upm@figtex@figremove{#1}}%
}

\newcommand{\upm@mfigurewtex}[5][ht]{
	\begin{figure}[#1]%
		\begin{center}%
			\resizebox{\upm@figtex@remove@width@param{#2}}{!}{\input{#3.pstex_t}}%
			\caption{#4}%
			\label{fig:#5}%
		\end{center}%
	\end{figure}%
	\upm@figtex@restore%
}
\newcommand{\upm@mfigurewtexstar}[5][ht]{
	\begin{figure*}[#1]%
		\begin{center}%
			\resizebox{\upm@figtex@remove@width@param{#2}}{!}{\input{#3.pstex_t}}%
			\caption{#4}%
			\label{fig:#5}%
		\end{center}%
	\end{figure*}%
	\upm@figtex@restore%
}
%-----
%\mfigurewtex[position]{width}{filename}{caption}{label}
\def\mfigurewtex{\@ifstar\upm@mfigurewtexstar\upm@mfigurewtex}

%----------------------------------------
% TABLES
%----------------------------------------

%title of a table
\def\upm@fmt@table@title#1{\color{fronttableheader}{\bfseries #1}}
%title of columns
\def\upm@fmt@table@column@title#1{\mbox{}\hfil{\itshape \mbox{\color{fronttableheader}{#1}}}\hfil\mbox{}}
%table's colors
\definecolor{backtableheader}{rgb}{0.92,0.94,1}
\definecolor{fronttableheader}{rgb}{0.23,0.33,0.48}

%List of functions able to build an header
\newif\ifupm@havetitle
\def\upm@hline{\\\hline}
\expandafter\def\csname upm@tableheader@b@1\endcsname#1{\protect\upm@fmt@table@column@title{#1} \protect\\}
\expandafter\protected@edef\csname upm@tableheader@b@2\endcsname#1#2{%
	\protect\upm@fmt@table@column@title{#1} & \csname upm@tableheader@b@1\endcsname{#2}}
\expandafter\protected@edef\csname upm@tableheader@b@3\endcsname#1#2#3{%
	\protect\upm@fmt@table@column@title{#1} & \csname upm@tableheader@b@2\endcsname{#2}{#3}}
\expandafter\protected@edef\csname upm@tableheader@b@4\endcsname#1#2#3#4{%
	\protect\upm@fmt@table@column@title{#1} & \csname upm@tableheader@b@3\endcsname{#2}{#3}{#4}}
\expandafter\protected@edef\csname upm@tableheader@b@5\endcsname#1#2#3#4#5{%
	\protect\upm@fmt@table@column@title{#1} & \csname upm@tableheader@b@4\endcsname{#2}{#3}{#4}{#5}}
\expandafter\protected@edef\csname upm@tableheader@b@6\endcsname#1#2#3#4#5#6{%
	\protect\upm@fmt@table@column@title{#1} & \csname upm@tableheader@b@5\endcsname{#2}{#3}{#4}{#5}{#6}}
\expandafter\protected@edef\csname upm@tableheader@b@7\endcsname#1#2#3#4#5#6#7{%
	\protect\upm@fmt@table@column@title{#1} & \csname upm@tableheader@b@6\endcsname{#2}{#3}{#4}{#5}{#6}{#7}}
\expandafter\protected@edef\csname upm@tableheader@b@8\endcsname#1#2#3#4#5#6#7#8{%
	\protect\upm@fmt@table@column@title{#1} & \csname upm@tableheader@b@7\endcsname{#2}{#3}{#4}{#5}{#6}{#7}{#8}}
\expandafter\protected@edef\csname upm@tableheader@b@9\endcsname#1#2#3#4#5#6#7#8#9{%
	\protect\upm@fmt@table@column@title{#1} & \csname upm@tableheader@b@8\endcsname{#2}{#3}{#4}{#5}{#6}{#7}{#8}{#9}}

\expandafter\def\csname upm@tableheader@c@1\endcsname#1{\ifupm@havetitle\else\hline\fi\rowcolor{backtableheader}\csname upm@tableheader@b@1\endcsname{#1}}
\expandafter\def\csname upm@tableheader@c@2\endcsname#1#2{\ifupm@havetitle\else\hline\fi\rowcolor{backtableheader}\csname upm@tableheader@b@2\endcsname{#1}{#2}}
\expandafter\def\csname upm@tableheader@c@3\endcsname#1#2#3{\ifupm@havetitle\else\hline\fi\rowcolor{backtableheader}\csname upm@tableheader@b@3\endcsname{#1}{#2}{#3}}
\expandafter\def\csname upm@tableheader@c@4\endcsname#1#2#3#4{\ifupm@havetitle\else\hline\fi\rowcolor{backtableheader}\csname upm@tableheader@b@4\endcsname{#1}{#2}{#3}{#4}}
\expandafter\def\csname upm@tableheader@c@5\endcsname#1#2#3#4#5{\ifupm@havetitle\else\hline\fi\rowcolor{backtableheader}\csname upm@tableheader@b@5\endcsname{#1}{#2}{#3}{#4}{#5}}
\expandafter\def\csname upm@tableheader@c@6\endcsname#1#2#3#4#5#6{\ifupm@havetitle\else\hline\fi\rowcolor{backtableheader}\csname upm@tableheader@b@6\endcsname{#1}{#2}{#3}{#4}{#5}{#6}}
\expandafter\def\csname upm@tableheader@c@7\endcsname#1#2#3#4#5#6#7{\ifupm@havetitle\else\hline\fi\csname upm@tableheader@b@7\endcsname{#1}{#2}{#3}{#4}{#5}{#6}{#7}}
\expandafter\def\csname upm@tableheader@c@8\endcsname#1#2#3#4#5#6#7#8{\ifupm@havetitle\else\hline\fi\csname upm@tableheader@b@8\endcsname{#1}{#2}{#3}{#4}{#5}{#6}{#7}{#8}}
\expandafter\def\csname upm@tableheader@c@9\endcsname#1#2#3#4#5#6#7#8#9{\ifupm@havetitle\else\hline\fi\rowcolor{backtableheader}\csname upm@tableheader@b@9\endcsname{#1}{#2}{#3}{#4}{#5}{#6}{#7}{#8}{#9}}

%-----
%\mtabular[width]{ncolumns}{columns}
\newenvironment{mtabular}[3][\linewidth]{%
	\upm@havetitlefalse
	\newcommand{\tabulartitle}[1]{\hline\multicolumn{#2}{>{\columncolor{backtableheader}}c}{\upm@fmt@table@title{##1}}\upm@havetitletrue \upm@hline}%
	\expandafter\let\expandafter\tabularheader\csname upm@tableheader@c@#2\endcsname%
	\tabularx{#1}{#3}%
}{%
	\endtabularx%
}

%-----
%\mtable[position]{width}{ncolumns}{columns}{caption}{label}
\newenvironment{mtable}[6][ht]{%
	\table[#1]\center%
	\global\protected@edef\upm@table@caption{#5}%
	\global\protected@edef\upm@table@label{tab:#6}%
	\newcommand{\captionastitle}{\tabulartitle{\upm@table@caption}}%
	\mtabular[#2]{#3}{#4}%
}{%
	\endmtabular%
	\caption{\upm@table@caption}%
	\label{\upm@table@label}%
	\endcenter\endtable%
	\let\upm@table@caption\relax%
	\let\upm@table@label\relax%
}

%-----
%\tabref{label}
\newcommand{\tabref}[1]{\ref{tab:#1}}
%-----
%\tabpageref{label}
\newcommand{\tabpageref}[1]{\pageref{tab:#1}}

%----------------------------------------
% PARAGRAPHS
%----------------------------------------
\setlength{\parindent}{0pt}

%----------------------------------------
% COLORIZED SECTION'S TITLES
%----------------------------------------
\definecolor{titlecolor}{rgb}{0.93,0.41,0}
\definecolor{maintitlecolor}{rgb}{0.24,0.33,0.48}

\gdef\upm@format@chapternum#1{\textcolor{maintitlecolor}{\huge \scshape #1}}
\gdef\upm@format@chaptertitle#1{\textcolor{maintitlecolor}{
		\Huge\scshape {#1}}}
\gdef\upm@format@sectionnum#1{\textcolor{titlecolor}{#1}}
\gdef\upm@format@sectiontitle#1{\textcolor{titlecolor}{#1}}

\gdef\@makechapterhead#1{%
  \vspace*{50\p@}%
  {\parindent \z@ \raggedright \normalfont
    \ifnum \c@secnumdepth >\m@ne
      \if@mainmatter
        \upm@format@chapternum{\@chapapp\space \thechapter}
        \par\nobreak
        \vskip 20\p@
      \fi
    \fi
    \interlinepenalty\@M
    \doublespacing
    \upm@format@chaptertitle{#1}\par\nobreak
    \vskip 40\p@
  }
}
\gdef\@makeschapterhead#1{%
  \vspace*{50\p@}%
  {\parindent \z@ \raggedright
    \normalfont
    \interlinepenalty\@M
    \doublespacing
    \upm@format@chaptertitle{#1}\par\nobreak
    \vskip 40\p@
  }
}
\renewcommand{\section}{\@startsection{section}{1}{\z@}{-3.5ex \@plus -1ex \@minus -.2ex}{2.3ex \@plus.2ex}{\normalfont\Large\scshape}}
\renewcommand{\subsection}{\@startsection{subsection}{2}{\z@}{-3.25ex\@plus -1ex \@minus -.2ex}{1.5ex \@plus .2ex}{\normalfont\large\scshape}}
\renewcommand{\subsubsection}{\@startsection{subsubsection}{3}{\z@}{-3.25ex\@plus -1ex \@minus -.2ex}{1.5ex \@plus .2ex}{\normalfont\normalsize\scshape}}
\let\upm@format@sect@old\@sect
\gdef\@sect#1#2#3#4#5#6[#7]#8{\upm@format@sect@old{#1}{#2}{#3}{#4}{#5}{#6}[#7]{\upm@format@sectiontitle{#8}}}
\let\upm@format@ssect@old\@ssect
\gdef\@ssect#1#2#3#4#5{\upm@format@ssect@old{#1}{#2}{#3}{#4}{\upm@format@sectiontitle{#5}}}
\gdef\@seccntformat#1{\upm@format@sectionnum{\csname the#1\endcsname/}\quad}

%----------------------------------------
% PAGE LAYOUT
%----------------------------------------
% Update the formatof the saved pages and sections
\AtBeginDocument{
  \renewcommand{\chaptermark}[1]{\markboth{\textsc{#1}}{}}
  \renewcommand{\sectionmark}[1]{\markright{\thesection\ \textsc{#1}}}
  \renewcommand{\@mkboth}[2]{%
    \let\upm@doc@MakeUppercase\MakeUppercase%
    \gdef\MakeUppercase##1{##1}%
    \chaptermark{#1}%
    \let\MakeUppercase\upm@doc@MakeUppercase%
    \let\upm@doc@MakeUppercase\relax%
    }
}
% Make sure that the page before a part or
% a chapter title was empty
\AtBeginDocument{%
  \renewcommand{\cleardoublepage}{%
    \clearpage%
    \if@twoside\ifodd\c@page%
    \else%
    \thispagestyle{facingtochapter}%
    \hbox{}\newpage%
    \if@twocolumn\hbox{}\newpage%
    \fi\fi\fi%
    }
  \newcommand{\ps@facingtochapter}{\ps@empty}
  }

%----------------------------------------
% BIBLIOGRAPHY
%----------------------------------------

%-----
%\bibsize{size}
\newcommand{\bibsize}[1]{\gdef\upm@bibsize{#1}}

\gdef\upm@bibsize{\small}

\gdef\@biblabel#1{{\upm@bibsize{[#1]}}}

\gdef\@lbibitem[#1]#2{\item[\@biblabel{#1}\hfill]\upm@bibsize\if@filesw{%
	\let\protect\noexpand\immediate\write\@auxout{\string\bibcite{#2}{#1}}}\fi\ignorespaces}

\gdef\@bibitem#1{\item\upm@bibsize\if@filesw%
	\immediate\write\@auxout{\string\bibcite{#1}{\the\value{\@listctr}}}\fi\ignorespaces}

%-----
\let\upm@bibliographystyle\bibliographystyle
\let\upm@bibliography\bibliography
\gdef\upm@bibstyle{abbr}
\renewcommand{\bibliographystyle}[1]{\gdef\upm@bibstyle{#1}}
\renewcommand{\bibliography}[1]{%
	\upm@bibliographystyle{\upm@bibstyle}%
	\upm@bibliography{#1}%
}

%----------------------------------------
% TABLE OF CONTENT
%----------------------------------------
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}

%----------------------------------------
% ENUMERATIONS
%----------------------------------------
\newcounter{upm@fmt@savedcounter}

\newcommand{\savecounter}[1]{%
	\setcounter{upm@fmt@savedcounter}{\value{#1}}%
}
\newcommand{\restorecounter}[1]{%
	\setcounter{#1}{\theupm@fmt@savedcounter}%
}
\newcommand{\saveenumcounter}{\savecounter{\@enumctr}}
\newcommand{\restoreenumcounter}{\restorecounter{\@enumctr}}
\newcommand{\setenumcounter}[1]{\setcounter{\@enumctr}{#1}\addtocounter{\@enumctr}{-1}}
\newcommand{\getenumcounter}{\value{\@enumctr}}

%----------------------------------------
% FOOTNOTE
%----------------------------------------

\newcommand{\upm@footnoteref}[1]{\mbox{\ensuremath{^{\text{\ref{footnote:#1}}}}}}
\newcommand{\upm@footnotepageref}[1]{\mbox{\ensuremath{^{\text{\ref{footnote:#1}}}_{\text{\tiny \vpageref[]{footnote:#1}}}}}}
\newcommand{\@namelet}[1]{\expandafter\let\csname #1\endcsname}

\newcommand{\upm@savefootnote}[2]{%
	\footnote{#1\label{footnote:#2}}%
	\global\@namelet{footnote:#2:cmd}\relax%
}
\newcommand{\upm@savefootnotestar}[2]{%
	\global\@namedef{footnote:#2:cmd}{%
		\upm@savefootnote{#1}{#2}%
	}%
}

\gdef\savefootnote{\@ifstar\upm@savefootnotestar\upm@savefootnote}

\newcommand{\upm@reffootnote}[1]{%
	\expandafter\ifx\csname footnote:#1:cmd\endcsname\relax%
		\upm@footnoteref{#1}%
	\else%
		\@nameuse{footnote:#1:cmd}%
	\fi\xspace%
} 
\newcommand{\upm@reffootnotestar}[1]{%
	\expandafter\ifx\csname footnote:#1:cmd\endcsname\relax%
		\upm@footnotepageref{#1}%
	\else%
		\@nameuse{footnote:#1:cmd}%
	\fi\xspace%
} 

\gdef\reffootnote{\@ifstar\upm@reffootnotestar\upm@reffootnote}

%----------------------------------------
% IMAGES IN PARAGRAPHS
%----------------------------------------

\newenvironment{umlinpar}[2][width=.45\linewidth]{%
\begin{window}[0,r,{\mbox{\hspace{.5cm}\includegraphics[#1]{#2}\vspace{.5cm}}},{}]
}{%
\end{window}}

%----------------------------------------
% DATE
%----------------------------------------

%Build a date this a supported format
%\makedate{day}{month}{year}
\let\makedate\upm@format@lang@makedate

%-----
%Replies the year corresponding to the given supported date
%\extractyear{date}
\let\extractyear\upm@format@lang@extractyear

%-----
%Replies the month corresponding to the given supported date
%\extractmonth{date}
\let\extractmonth\upm@format@lang@extractmonth

%-----
%Replies the day corresponding to the given supported date
%\extractday{date}
\let\extractday\upm@format@lang@extractday

% Redefine the today function
\AtBeginDocument{\global\edef\today{\makedate{\the\day}{\the\month}{\the\year}}}

%----------------------------------------
% PEOPLE NAME
%----------------------------------------

%\upmmakename[von]{firstname}{lastname}{separator}
\newcommand{\upmmakename}[4][\relax]{%
	\ifx#1\relax%
		{\mbox{\small #2}#4\textsc{#3}}%
	\else%
		{\mbox{\small #2}#4\mbox{\small #1}#4\textsc{#3}}%
	\fi%
	\xspace%
}

%\makename[von]{firstname}{lastname}
\newcommand{\makename}[3][\relax]{%
	\upmmakename[#1]{#2}{#3}{\ }
}

%----------------------------------------
% INLINE ENUMERATION
%----------------------------------------

\newcounter{@@upm@fmt@inlineenumeration}
\newenvironment{inlineenumeration}{%
	\renewcommand{\item}{{(\roman{@@upm@fmt@inlineenumeration}){\addtocounter{@@upm@fmt@inlineenumeration}{1}}}~}%
	\setcounter{@@upm@fmt@inlineenumeration}{1}%
}{%
}

%----------------------------------------
% SIZE MANAGEMENT
%----------------------------------------
\newenvironment{upmfontsize}[1]{%
	\begingroup%
	\let\upm@Huge\Huge%
	\let\upm@huge\huge%
	\let\upm@normalsize\normalsize%
	\let\upm@small\small%
	\let\upm@scriptsize\scriptsize%
	\let\upm@footnotesize\footnotesize%
	\let\upm@tiny\tiny%
	%
	\ifx#1\Huge%
		\let\Huge\upm@Huge%
		\let\huge\upm@Huge%
		\let\small\upm@huge%
		\let\scriptsize\upm@normalsize%
		\let\footnotesize\upm@small%
		\let\tiny\upm@scriptsize%
	\else\ifx#1\huge%
		\let\Huge\upm@Huge%
		\let\huge\upm@Huge%
		\let\small\upm@normalsize%
		\let\scriptsize\upm@small%
		\let\footnotesize\upm@scriptsize%
		\let\tiny\upm@footnotesize%
	\else\ifx#1\small%
		\let\Huge\upm@huge%
		\let\huge\upm@normalsize%
		\let\small\upm@scriptsize%
		\let\scriptsize\upm@footnotesize%
		\let\footnotesize\upm@tiny%
		\let\tiny\upm@tiny%
	\else\ifx#1\scriptsize%
		\let\Huge\upm@normalsize%
		\let\huge\upm@small%
		\let\small\upm@footnotesize%
		\let\scriptsize\upm@tiny%
		\let\footnotesize\upm@tiny%
		\let\tiny\upm@tiny%
	\else\ifx#1\footnotesize%
		\let\Huge\upm@small%
		\let\huge\upm@scriptsize%
		\let\small\upm@tiny%
		\let\scriptsize\upm@tiny%
		\let\footnotesize\upm@tiny%
		\let\tiny\upm@tiny%
	\else\ifx#1\tiny%
		\let\Huge\upm@scriptsize%
		\let\huge\upm@footnotesize%
		\let\small\upm@tiny%
		\let\scriptsize\upm@tiny%
		\let\footnotesize\upm@tiny%
		\let\tiny\upm@tiny%
	\fi%
	\fi%
	\fi%
	\fi%
	\fi%
	\fi%
	#1%
}{\endgroup}

\endinput
