% $Id: hume.sty,v 1.17 2007/04/06 20:11:46 jost Exp $

%%% Makros connected to notations solely used in Research on Hume, Ham, EmBounded...
%%%
%%% Steffen Jost, 06.02.2006 for for www.EmBounded.org
%%%

\ProvidesPackage{rtyps}[2006/02/27 - A package for papers about HUME.]
\NeedsTeXFormat{LaTeX2e}
\RequirePackage{ifthen}

%%%
%%% Stretchable Symbols (mostly VDASHES) having weird annotations affixed to them
%%%
\newcommand{\rtypssize}{\scriptsize}

%% A cute stretchable \vdash 
\newlength{\lenupper}
\newlength{\lenlower}
\newlength{\normalheight}
\newlength{\heilower}
\newlength{\tmax}
\newlength{\tdiff}
\newlength{\decomargin}%The width-difference that is ignored for aligning in \rtyps, defined below...
\newlength{\lenarrh}
\newsavebox{\boxupper}%
\newsavebox{\boxlower}%
\newsavebox{\boxcf}%

\sbox{\boxupper}{\rtypssize\ensuremath{m_0''''}}%
\sbox{\boxlower}{\rtypssize\ensuremath{m}}%
\settowidth{\lenlower}{\usebox{\boxlower}}%
\settowidth{\decomargin}{\usebox{\boxupper}}%
\addtolength{\decomargin}{-\lenlower}%

%%% This is the original version, both arguments are strictly aligned left!
%\newcommand{\rtyps}[2]{% %Written by S.Jost, inspired by someone else, whose code I was not allowed to see.
%\sbox{\boxupper}{\scriptsize\ensuremath{#1}}%
%\sbox{\boxlower}{\scriptsize\ensuremath{#2}}%
%\settowidth{\lenupper}{\usebox{\boxupper}}%
%\settowidth{\lenlower}{\usebox{\boxlower}}%
%\ifthenelse{\lenupper > \lenlower}{\setlength{\tmax}{\lenupper}}{\setlength{\tmax}{\lenlower}}%
%%\addtolength{\tmax}{-1.4pt}%
%\addtolength{\tmax}{2.8pt}%
%\raisebox{1.5pt}{\ensuremath{~\,%
%%      \rule[-1.5pt]{0.47pt}{8pt}\rule[2.5pt]{\tmax}{0.47pt}^{\hspace*{-\tmax}\,{\usebox{\boxupper}}}_{\hspace*{-\tmax}\,\raisebox{-1.4pt}{\usebox{\boxlower}}}}%
%      \rule[-1.5pt]{0.5pt}{8pt}\rule[2.5pt]{\tmax}{0.5pt}^{\hspace*{-\tmax}\hspace*{2pt}\raisebox{0.7pt}{\usebox{\boxupper}}}_{\hspace*{-\tmax}\hspace*{2pt}\raisebox{-1.5pt}{\usebox{\boxlower}}}}%
%  ~\,}%set RAISEBOX-VALUE 0pt -> -1.38pt if you intend to uses primes like in m' as lower subscripts in combination with longer upper subscripts.
%}%

\newcommand{\rtyps}[2]{% %Written by S.Jost, inspired by someone else, whose code I was not allowed to see. Maybe using the {calc} package might simplify the code, which currently works without the calc-package
\sbox{\boxupper}{\rtypssize\ensuremath{#1}}%
\sbox{\boxlower}{\rtypssize\ensuremath{#2}}%
\settowidth{\lenupper}{\usebox{\boxupper}}%
\settowidth{\lenlower}{\usebox{\boxlower}}%
\ifthenelse{\lengthtest{\lenupper > \lenlower}}{\setlength{\tmax}{\lenupper}}{\setlength{\tmax}{\lenlower}}%
\ifthenelse{\lengthtest{1ex > \tmax}}{\setlength{\tmax}{1ex}}{}%
\setlength{\tdiff}{2\tmax}%
\addtolength{\tdiff}{-\lenupper}%
\addtolength{\tdiff}{-\lenlower}%
\ifthenelse{\tdiff < \decomargin}%
{% Leftaligned placement
\addtolength{\tmax}{2pt}%
\setlength{\lenupper}{2\tmax}
\setlength{\lenlower}{2\tmax}
\addtolength{\tmax}{3pt}%
}%
{% Center the smaller one
\addtolength{\tmax}{4pt}%
\addtolength{\lenupper}{\tmax}%
\addtolength{\lenlower}{\tmax}%
\addtolength{\tmax}{1pt}%
}%
%\ifslides{%
  %%%SLIDES:
%  \raisebox{1.5pt}{%
%  \ensuremath{~\,\rule[-5.5pt]{1pt}{16pt}\rule[2.5pt]{\tmax}{1pt}^{\hspace*{-0.5\lenupper}\raisebox{0.7pt}{\usebox{\boxupper}}}_{\hspace*{-0.5\lenlower}\raisebox{-7pt}{\usebox{\boxlower}}}}~\,}%  
%  }{%
  %%%PAPER:
  \raisebox{1.5pt}{\ensuremath{~\,\rule[-2.5pt]{0.6pt}{9pt}\rule[1.9pt]{\tmax}{0.6pt}^{\hspace*{-0.5\lenupper}\raisebox{-1.2pt}{\usebox{\boxupper}}}_{\hspace*{-0.5\lenlower}\raisebox{-1.5pt}{\usebox{\boxlower}}}}~\,}%
%  }%
}%

\newcommand{\rtypscf}[2]{% %Written by S.Jost, inspired by someone else, whose code I was not allowed to see. Maybe using the {calc} package might simplify the code, which currently works without the calc-package
\sbox{\boxupper}{\rtypssize\ensuremath{#1}}%
\sbox{\boxlower}{\rtypssize\ensuremath{#2}}%
\sbox{\boxcf}{\tiny\ensuremath{\mathit{CF}}}%
\settowidth{\lenupper}{\usebox{\boxupper}}%
\settowidth{\lenlower}{\usebox{\boxlower}}%
\ifthenelse{\lengthtest{\lenupper > \lenlower}}{\setlength{\tmax}{\lenupper}}{\setlength{\tmax}{\lenlower}}%
\ifthenelse{\lengthtest{1ex > \tmax}}{\setlength{\tmax}{1ex}}{}%
\setlength{\tdiff}{2\tmax}%
\addtolength{\tdiff}{-\lenupper}%
\addtolength{\tdiff}{-\lenlower}%
\ifthenelse{\tdiff < \decomargin}%
{% Leftaligned placement
\addtolength{\tmax}{2pt}%
\setlength{\lenupper}{2\tmax}
\setlength{\lenlower}{2\tmax}
\addtolength{\tmax}{3pt}%
}%
{% Center the smaller one
\addtolength{\tmax}{4pt}%
\addtolength{\lenupper}{\tmax}%
\addtolength{\lenlower}{\tmax}%
\addtolength{\tmax}{1pt}%
}%
%\ifslides{%
  %%%SLIDES:
%  \raisebox{1.5pt}{%
%  \ensuremath{~\,\rule[-5.5pt]{1pt}{16pt}\rule[2.5pt]{\tmax}{1pt}^{\hspace*{-0.5\lenupper}\raisebox{0.7pt}{\usebox{\boxupper}}}_{\hspace*{-0.5\lenlower}\raisebox{-7pt}{\usebox{\boxlower}}}}~\,}%  
%  }{%
  %%%PAPER:
  \raisebox{1.5pt}{\ensuremath{~\;\!\raisebox{1.2pt}{\usebox{\boxcf}}\:\!\rule[-1pt]{0.57pt}{8pt}\rule[3pt]{\tmax}{0.57pt}^{\hspace*{-0.5\lenupper}\raisebox{1.2pt}{\usebox{\boxupper}}}_{\hspace*{-0.5\lenlower}\raisebox{-1.5pt}{\usebox{\boxlower}}}}~\,}%
%  }%
}%
