%%
%% This is file `cals.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% cals.dtx  (with options: `package')
%% cell.dtx  (with options: `package')
%% span.dtx  (with options: `package')
%% table.dtx  (with options: `package')
%% lltokens.dtx  (with options: `package')
%% decor.dtx  (with options: `package')
%% colsep.dtx  (with options: `package')
%% rowsep.dtx  (with options: `package')
%% rtl.dtx  (with options: `package')
%% 
%% This is a generated file.
%% 
%% Copyright (C) 2004 by Oleg Parashchenko <olpa@uucode.com>
%% 
%% This file may be distributed and/or modified under the conditions of
%% the LaTeX Project Public License, either version 1.2 of this license
%% or (at your option) any later version.  The latest version of this
%% license is in:
%% 
%%    http://www.latex-project.org/lppl.txt
%% 
%% and version 1.2 or later is part of all distributions of LaTeX version
%% 1999/12/01 or later.
%% 
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{cals}
    [2016/11/23 CALS tables v.2.4.1]



\newcommand\cals@cell[3]{}
\def\cals@cell#1#2{%
\vbox\bgroup%
\hsize=#1
\linewidth=#1
\leftskip=\cals@paddingL %
\rightskip=\cals@paddingR %
\ifdim #2>0pt %
 \vskip-#2
\fi
\vskip\cals@paddingT %
\vskip-\parskip %
\prevdepth=\cals@paddingD %
\bgroup\aftergroup\cals@cell@end
\cals@AtBeginCell\let\next=% eat '{' of the content
}%{Implicit content}

\def\cals@cell@end{\vfil\vskip\cals@paddingB
\cals@AtEndCell\egroup % finish vbox
\cals@celll@end}

\newcommand\cell[1]{}
\def\cell{%
\llt@rot\cals@colwidths
\let\cals@cell@width=\llt@car
\setbox0=\cals@cell\cals@cell@width{0pt}%
}

\let\cals@AtBeginCell=\relax
\let\cals@AtEndCell=\relax

\newcommand\cals@width@cell@put@row{%
\ifdim \cals@cell@width=\wd0 \relax \else \wd0=\cals@cell@width \fi
\setbox\cals@current@row=\hbox{\unhbox\cals@current@row\box0 }}%

\newcommand\cals@celll@end{%
\cals@width@cell@put@row
\cals@decor@next\cals@cell@width}

\newcommand\spancontent[1]{}
\def\spancontent{%
\let\cals@tmp=\cals@celll@end
\let\cals@cell@width=\cals@span@width
\def\cals@celll@end{%
  \cals@width@cell@put@row%
  \let\cals@celll@end=\cals@tmp}%
\setbox0=\cals@cell{\cals@span@width}{\cals@span@height}%
}%{Implicit content}


\newskip\cals@paddingL
\newskip\cals@paddingR
\newskip\cals@paddingT
\newskip\cals@paddingB

\newcommand{\cals@setpadding}[1]{%
\setbox0=\hbox{#1}%
\dimen0=\ht0 \advance\dimen0 by \dp0 \divide\dimen0 by 2
\cals@paddingL=\dimen0 \relax
\cals@paddingR=\cals@paddingL
\cals@paddingT=\cals@paddingL
\cals@paddingB=\cals@paddingL
}

\newdimen\cals@paddingD

\newcommand{\cals@setcellprevdepth}[1]{%
\setbox0=\vbox{\prevdepth=0pt #1}%
\setbox1=\vbox{#1}%
\dimen0=\ht0 \advance\dimen0 by \dp0 %
\advance\dimen0 by -\ht1 \advance\dimen0 by -\dp1%
\cals@paddingD=\dimen0 }

\newcommand\alignL{%
\cals@vfillDrop\cals@paddingL
\cals@vfillDrop\cals@paddingR}

\newcommand\alignC{%
\cals@vfillAdd\cals@paddingL
\cals@vfillAdd\cals@paddingR}

\newcommand\alignR{%
\cals@vfillAdd\cals@paddingL
\cals@vfillDrop\cals@paddingR}

\newcommand\cals@vfillAdd[1]{\ifnum\gluestretchorder#1>1\relax\else
\dimen0=#1\relax #1=\dimen0 plus 1fill\relax \fi}
\newcommand\cals@vfillDrop[1]{\ifnum\gluestretchorder#1>0\relax
\dimen0=#1\relax #1=\dimen0\relax \fi}


\newbox\cals@current@row

\newcommand\colwidths[1]{}
\def\colwidths#{\edef\cals@colwidths}
\def\cals@colwidths{{100pt}}


\newcommand\brow{%
\cals@updateRspanMarkers
\setbox\cals@current@row=\hbox{}%
\cals@decor@begin}

\newcommand\erow{%
\cals@reheight@cells\cals@current@row
\cals@last@row@height=\ht\cals@current@row\relax
\cals@decor@end\cals@lastWidth
\ht\cals@current@cs=\ht\cals@current@row
\cals@row@dispatch
}

\newcommand\cals@reheight@cells[1]{%
\dimen0=\ht#1\relax
\setbox2=\hbox{}%
\def\next{%
 \setbox4=\lastbox
 \ifvoid4
   \def\next{\global\setbox2=\box2}%
 \else
   \dimen4=\wd4
   \setbox4=\vbox to \dimen0{\unvbox4}%
   \ifdim \dimen4=\wd4 \relax \else \wd4=\dimen4 \fi
   \setbox2=\hbox{\box4\unhbox2 }%
 \fi
 \next}%
\setbox0=\hbox{\unhbox#1\next}%
\setbox#1=\box2 }



\def\cals@spanq@heights{}

\newcommand\cals@span@get{%
\llt@decons\cals@spanq@heights \cals@span@height=\llt@car\relax}

\newcommand\cals@span@put{%
\edef\cals@tmp{\the\cals@span@height}\llt@snoc\cals@spanq@heights\cals@tmp}

\newcommand\nullcell[1]{%
\let\cals@span@ifL=\cals@iffalse
\let\cals@span@ifT=\cals@iffalse
\let\cals@span@ifR=\cals@iffalse
\let\cals@span@ifB=\cals@iffalse
\def\next##1{\ifx\relax##1\let\next=\relax \else
 \expandafter\let\csname cals@span@if##1\endcsname=\cals@iftrue \fi
 \next}%
\uppercase{\next #1}\relax
\llt@rot\cals@colwidths \let\cals@nullcell@width=\llt@car
\cals@span@ifL\iftrue
 \cals@span@ifT\iftrue
   \cals@span@height=0pt %
 \else
   \cals@span@get
   \advance\cals@span@height by \cals@last@row@height\relax
 \fi
 \cals@span@ifB\iftrue \else
  \let\cals@ifInRspan=\cals@iftrue
  \let\cals@ifLastRspanRow=\cals@iffalse
 \fi
 \let\cals@span@borderL=\cals@borderL \let\cals@span@borderT=\cals@borderT
 \let\cals@span@borderR=\cals@borderR \let\cals@span@borderB=\cals@borderB
\fi
\cals@span@ifR\iftrue
 \cals@span@ifB\iftrue \relax \else \cals@span@put \fi
\fi
\cals@span@ifB\iftrue
 \cals@span@ifL\iftrue
  \cals@span@width=\cals@nullcell@width\relax
 \else
  \advance\cals@span@width by \cals@nullcell@width\relax
 \fi
\else
 \setbox\cals@current@row=\hbox{%
   \unhbox\cals@current@row
   \vbox{\hbox to\cals@nullcell@width{}\vfil}}%
\fi
\cals@span@ifL\iftrue \let\cals@borderL=\cals@span@borderL
  \else \def\cals@borderL{0pt}\fi
\cals@span@ifT\iftrue \let\cals@borderT=\cals@span@borderT
  \else \def\cals@borderT{0pt}\fi
\cals@span@ifR\iftrue \let\cals@borderR=\cals@span@borderR
  \else \def\cals@borderR{0pt}\fi
\cals@span@ifB\iftrue \let\cals@borderB=\cals@span@borderB
  \else \def\cals@borderB{0pt}\fi
\cals@decor@next\cals@nullcell@width
\let\cals@borderL=\cals@span@borderL \let\cals@borderR=\cals@span@borderR
\let\cals@borderT=\cals@span@borderT \let\cals@borderB=\cals@span@borderB
}

\newdimen\cals@span@width
\newdimen\cals@span@height



\newcommand\cals@updateRspanMarkers{%
\ifx \empty\cals@spanq@heights
 \let\cals@ifInRspan=\cals@iffalse
\else
 \let\cals@ifInRspan=\cals@iftrue
\fi
\let\cals@ifLastRspanRow=\cals@iftrue}

\newcommand\cals@row@dispatch{%
\ifx b\cals@current@context
 \cals@ifInRspan\iftrue
  \cals@row@dispatch@span
 \else
  \cals@row@dispatch@nospan
 \fi
\else
 \cals@row@dispatch@nospan
\fi}

\newcommand\cals@row@dispatch@nospan{%
\let\cals@last@context@bak=\cals@last@context
\ifx h\cals@current@context \else
\ifx f\cals@current@context \else
\cals@ifbreak\iftrue
 \setbox\cals@backup@row=\box\cals@current@row
 \setbox\cals@backup@cs=\box\cals@current@cs
 \let\cals@backup@rs@above=\cals@current@rs@above
 \let\cals@backup@rs@below=\cals@current@rs@below
 \let\cals@backup@context=\cals@current@context
 \cals@tfoot@tokens
 \lastrule
 \cals@issue@break
 \cals@thead@tokens
 \setbox\cals@current@row=\box\cals@backup@row
 \setbox\cals@current@cs=\box\cals@backup@cs
 \let\cals@current@rs@above=\cals@backup@rs@above
 \let\cals@current@rs@below=\cals@backup@rs@below
 \let\cals@current@context=\cals@backup@context
\fi\fi\fi
\ifdim\wd\cals@current@row>\hsize\relax
\def\cals@tohsize{}%
\fi
\cals@issue@row
\ifx b\cals@last@context
  {\dimen0=\pagetotal\relax
  \advance\dimen0 by \cals@tfoot@height\relax
  \advance\dimen0 by -\pagegoal
  \ifdim\dimen0>0pt\relax
    \vskip\dimen0
    \penalty9999 % with 10000, the output page builder is not called
    \vskip-\dimen0\relax
  \fi
  }%
\fi
}

\newcommand\cals@row@dispatch@span{%
\ifvoid\cals@backup@row
 \setbox\cals@backup@row=\vbox{\box\cals@current@row}%
 \setbox\cals@backup@cs=\box\cals@current@cs
 \let\cals@backup@rs@above=\cals@current@rs@above
 \let\cals@backup@last@rs@below=\cals@last@rs@below
 \let\cals@backup@context=\cals@last@context
 \cals@backup@leftskip=\leftskip\relax
 \cals@backup@rightskip=\rightskip\relax
 \let\cals@backup@tohsize=\cals@tohsize
 \leftskip=0pt\relax \rightskip=0pt\relax \def\cals@tohsize{}%
\else
 \setbox\cals@backup@row=\vbox{\unvbox\cals@backup@row
  \cals@issue@row}%
\fi
\let\cals@last@rs@below=\cals@current@rs@below
\let\cals@last@context=\cals@current@context
\cals@ifLastRspanRow\iftrue
 \setbox\cals@current@row=\box\cals@backup@row
 \setbox\cals@current@cs=\box\cals@backup@cs
 \let\cals@current@rs@above=\cals@backup@rs@above
 \let\cals@last@rs@below=\cals@backup@last@rs@below
 \let\cals@last@context=\cals@backup@context
 \leftskip=\cals@backup@leftskip
 \rightskip=\cals@backup@rightskip
 \let\cals@tohsize=\cals@backup@tohsize
 \cals@row@dispatch@nospan
\fi
}

\newbox\cals@backup@row
\newbox\cals@backup@cs
\newskip\cals@backup@leftskip
\newskip\cals@backup@rightskip




\newcommand\cals@ifbreak[1]{}
\def\cals@ifbreak{%
\let\cals@tmp=\cals@iffalse
\let\cals@tmpII=\cals@iftrue
\ifx\relax\cals@tbreak@tokens
 \ifinner\else
  \ifx h\cals@current@context \else
   \ifx f\cals@current@context \else
    \ifx h\cals@last@context \else
     \ifx n\cals@last@context \else
       \dimen0=\pagetotal\relax
       \advance\dimen0 by \ht\cals@current@row\relax
       %\showthe\ht\cals@current@row\relax
       \ifx \cals@tfoot@tokens\relax \else
         %\show\cals@tfoot@height\relax
         \advance\dimen0 by \cals@tfoot@height\relax
       \fi
       %\showthe\dimen0\relax
       \ifdim \dimen0>\pagegoal\relax
         \let\cals@tmp=\cals@tmpII
       \fi
 \fi\fi\fi\fi\fi
\else \let\cals@tmp=\cals@tmpII % tbreak@tokens
\fi
\cals@tmp}

\newcommand\cals@issue@break{\ifx \relax\cals@tbreak@tokens \penalty-10000 %
\else \cals@tbreak@tokens \fi
\let\cals@tbreak@tokens=\relax
\let\cals@last@context=n}

\newcommand\cals@tohsize{}
\newcommand\cals@set@tohsize{\def\cals@tohsize{}%
\ifnum\gluestretchorder\leftskip>0\relax \def\cals@tohsize{to \hsize}\fi
\ifnum\gluestretchorder\rightskip>0\relax \def\cals@tohsize{to \hsize}\fi
}

\newcommand\cals@hbox{}
\newcommand\cals@activate@rtl{\let\cals@hbox=\hboxR}
\newcommand\cals@deactivate@rtl{\let\cals@hbox=\hbox}
\cals@deactivate@rtl

\newcommand\cals@issue@rowsep@alone{%
\setbox0=\cals@hbox\cals@tohsize{%
 \cals@hskip@lr\leftskip\rightskip
 \cals@rs@sofar@reset
 \cals@rs@joinOne\cals@framers@width\cals@current@rs@above
 \cals@rs@sofar@end
 \cals@hskip@lr\rightskip\leftskip}%
\ht0=0pt \dp0=0pt \box0 }

\newcommand\cals@issue@rowsep{%
\ifx n\cals@last@context \cals@issue@rowsep@alone \else
 \ifx \cals@last@context\cals@current@context
   \let\cals@tmpIII=\cals@rs@width     \else
   \let\cals@tmpIII=\cals@bodyrs@width \fi
 \setbox0=\cals@hbox\cals@tohsize{%
  \cals@hskip@lr\leftskip\rightskip
  \cals@rs@sofar@reset
  \cals@rs@joinTwo\cals@tmpIII\cals@last@rs@below\cals@current@rs@above
  \cals@rs@sofar@end
  \cals@hskip@lr\rightskip\leftskip}%
 \ht0=0pt \dp0=0pt \box0 %
\fi}

\newdimen\cals@last@row@height

\newcommand\cals@issue@row{%
\nointerlineskip
\setbox0=\vtop{\cals@hbox\cals@tohsize{\cals@hskip@lr\leftskip\rightskip
\box\cals@current@cs \cals@hskip@lr\rightskip\leftskip}}%
\ht0=0pt\relax\box0
\nointerlineskip
\cals@issue@rowsep
\nointerlineskip
\cals@hbox\cals@tohsize{\cals@hskip@lr\leftskip\rightskip
\box\cals@current@row \cals@hskip@lr\rightskip\leftskip}%
\let\cals@last@rs@below=\cals@current@rs@below
\let\cals@last@context=\cals@current@context
\nobreak}


\newenvironment{calstable}[1][\cals@table@alignment]{%
\if@RTL\@RTLtabtrue\cals@activate@rtl\fi
\let\cals@thead@tokens=\relax
\let\cals@tfoot@tokens=\relax
\let\cals@tbreak@tokens=\relax
\cals@tfoot@height=0pt \relax
\let\cals@last@context=n%
\let\cals@current@context=b%
\parindent=0pt \relax%
\cals@setup@alignment{#1}%
\cals@setpadding{Ag}\cals@setcellprevdepth{Al}\cals@set@tohsize%
%% Alignment inside is independent on center/flushright outside
\parfillskip=0pt plus1fil\relax
\let\cals@borderL=\relax
\let\cals@borderR=\relax
\let\cals@borderT=\relax
\let\cals@borderB=\relax
\setbox\cals@backup@row=\box\voidb@x\relax
\cals@AtBeginTable
}{% End of the table
\cals@tfoot@tokens\lastrule\cals@AtEndTable}

\newcommand\cals@AtBeginTable{}%
\newcommand\cals@AtEndTable{}%

\newcommand\lastrule{%
\ifx r\cals@last@context \relax \else
 \let\cals@last@context=r%
 \nointerlineskip
 \let\cals@current@rs@above=\cals@last@rs@below\cals@issue@rowsep@alone%
\fi}

\newcommand\thead[1]{%
\def\cals@thead@tokens{\let\cals@current@context=h%
#1\let\cals@current@context=b}%
\cals@thead@tokens}

\newcommand\tfoot[1]{%
\def\cals@tfoot@tokens{\let\cals@current@context=f#1}%
\setbox0=\vbox{\cals@tfoot@tokens}%
\cals@tfoot@height=\ht0 \relax}

\newdimen\cals@tfoot@height

\newcommand\tbreak[1]{\def\cals@tbreak@tokens{#1}}

\newcommand\cals@table@alignment{l}

\def\llt@cons#1#2{%
\toks0=\expandafter{#1}%
\toks2=\expandafter{#2}%
\edef#2{\noexpand{\the\toks0}\the\toks2 }%
}

\def\llt@snoc#1#2{%
\toks0=\expandafter{#1}%
\toks2=\expandafter{#2}%
\edef#1{\the\toks0 \noexpand{\the\toks2}}%
}


\def\llt@decons@open#1{%
\def\llt@car{#1}%
\toks0=\llt@opengroup
}

\def\llt@decons#1{%
\let\llt@opengroup={%
\expandafter\llt@decons@open#1}%
\edef#1{\the\toks0}%
}

\def\llt@rot#1{%
\ifx#1\empty
\let\llt@car=\relax
\else
\llt@decons#1%
\llt@snoc#1\llt@car%
\fi
}

\def\llt@desnocII#1{
\ifx\empty#1%
\let\llt@tmp=n%
\else
\llt@snoc{\llt@newlist}{\llt@car}%
\let\llt@tmp=y%
\fi
}

\def\llt@desnoc#1{%
\def\llt@newlist{}%
\loop
\llt@decons{#1}%
\llt@desnocII{#1}%
\if y\llt@tmp \repeat
\let#1=\llt@newlist}




\newcommand\cals@cs@width{.4pt}
\newcommand\cals@framecs@width{0pt}
\newcommand\cals@rs@width{.4pt}
\newcommand\cals@framers@width{0pt}
\newcommand\cals@bodyrs@width{1.2pt}
\newcommand\cals@bgcolor{}





\newcommand\cals@decor@begin{\cals@csrow@begin\cals@rs@spec@begin}

\newcommand\cals@decor@next[1]{%
\cals@csrow@nextcell{#1}\cals@borderL\cals@borderR\cals@bgcolor
\cals@rs@spec@next{#1}\cals@lastLeftWidth\cals@borderT\cals@borderB}

\newcommand\cals@decor@end{%
\cals@csrow@end
\cals@rs@spec@end\cals@lastLeftWidth}


\newcommand\cals@widthII[2]{%
\ifx \relax#2\edef\cals@width{#1}%
        \else \edef\cals@width{#2}\fi}

\newcommand\cals@withWidthII[3]{%
\cals@widthII{#1}{#2}%
\ifdim \cals@width>0pt }

\newcommand\cals@withColorII[3]{%
\ifx \relax#2\edef\cals@color{#1}%
        \else \edef\cals@color{#2}\fi
\ifx \cals@color\empty \else\expandafter\expandafter\fi\iffalse\iftrue\fi}

\newcommand\cals@halfWidthToDimen[2]{%
\dimen#1=#2\relax \divide\dimen#1 by 2 }

\newcommand\cals@maxWidth[2]{%
\ifx \relax#1\relax
  \ifx \relax#2\let\cals@width=\relax
          \else \edef\cals@width{#2}\fi
\else
  \ifx \relax#2\relax
    \edef\cals@width{#1}%
  \else
    \ifdim #1>#2 \edef\cals@width{#1}%
           \else \edef\cals@width{#2}\fi\fi\fi}

\def\cals@iftrue#1{\iftrue}
\def\cals@iffalse#1{\iffalse}


\newcommand\cals@cs@outOne[3]{%
\ifx \relax#1%
\else
 \cals@withColorII\cals@bgcolor{#3}\iftrue
  \textcolor{\cals@color}{\vrule depth0pt width#1 }%
  \hskip -#1\relax
 \fi
\fi
\cals@withWidthII\cals@cs@width{#2}\iftrue
 \cals@halfWidthToDimen0 \cals@width %
 \hskip -\dimen0 %
 \vrule depth0pt width\cals@width\relax
 \hskip -\dimen0 %
\fi
\let\cals@lastLeftWidth=\cals@width
\ifx \relax#1\else \hskip#1 \fi
}

\newbox\cals@current@cs

\newcommand\cals@csrow@begin{%
\setbox\cals@current@cs=\box\voidb@x %
\let\cals@lastWidth=\relax}

\newcommand\cals@csrow@nextcell[4]{%
\ifvoid\cals@current@cs
  \toks0=\expandafter{\cals@cs@width}%
  \def\next{\edef\cals@cs@width{\the\toks0}}%
  \edef\cals@cs@width{\cals@framecs@width}%
\else \let\next=\relax \fi
\cals@maxWidth\cals@lastWidth{#2}%
\setbox\cals@current@cs=\hbox{\unhbox\cals@current@cs
    \cals@cs@outOne{#1}\cals@width{#4}%
    \global\let\cals@tmp=\cals@lastLeftWidth}%
\let\cals@lastLeftWidth=\cals@tmp
\let\cals@lastWidth=#3%
\next}

\newcommand\cals@csrow@end{%
\ifx \relax\cals@lastWidth
 \let\cals@width=\cals@framecs@width
\else
 \let\cals@width=\cals@lastWidth
\fi
\cals@csrow@nextcell\relax\cals@width\relax\relax}


\newcommand\cals@rs@pack[5]{%
\edef#1{\noexpand{#2\noexpand}\noexpand{#3\noexpand}\noexpand{#4\noexpand}%
 \ifx \relax#5\relax \else \noexpand{#5\noexpand}\fi }}

\newcommand\cals@rs@unpack[5]{%
\def\cals@tmp##1##2##3##4{\edef#2{##1}\edef#3{##2}\edef#4{##3}%
 \ifx\relax##4\let#5=\relax \else \edef#5{##4}\fi}%
\expandafter\cals@tmp#1}



\newcommand\cals@rs@spec@begin{%
\def\cals@current@rs@above{}%
\def\cals@current@rs@below{}%
\let\cals@rs@spec@ll=\relax}

\newcommand\cals@rs@spec@next[4]{
\cals@rs@spec@nextII#2
\let\cals@rs@spec@ll=#1%
\let\cals@rs@spec@bl=#2%
\let\cals@rs@spec@bt=#3%
\let\cals@rs@spec@bb=#4%
}

\newcommand\cals@rs@spec@nextII[1]{%
\ifx \relax\cals@rs@spec@ll \else
 \cals@rs@pack\cals@tmp\cals@rs@spec@ll\cals@rs@spec@bl#1\cals@rs@spec@bt
 \llt@snoc\cals@current@rs@above\cals@tmp
 \cals@rs@pack\cals@tmp\cals@rs@spec@ll\cals@rs@spec@bl#1\cals@rs@spec@bb
 \llt@snoc\cals@current@rs@below\cals@tmp
\fi
}

\newcommand\cals@rs@spec@end[1]{}
\let\cals@rs@spec@end=\cals@rs@spec@nextII

\newcommand\cals@rs@sofar@length{}
\newcommand\cals@rs@sofar@borderl{}
\newcommand\cals@rs@sofar@borderr{}
\newcommand\cals@rs@sofar@width{}

\newcommand\cals@rs@sofar@reset{\let\cals@rs@sofar@width=\relax}

\newcommand\cals@rs@sofar@end{\ifx\relax\cals@rs@sofar@width
  \else\cals@rs@sofar@out\fi}

\newcommand\cals@rs@sofar@next[4]{%
\ifx\relax\cals@rs@sofar@width
 \let\cals@rs@sofar@length=#1%
 \let\cals@rs@sofar@borderl=#2%
 \let\cals@rs@sofar@borderr=#3%
 \let\cals@rs@sofar@width=#4%
\else
 \ifdim \cals@rs@sofar@width=#4\relax
  \dimen0=\cals@rs@sofar@length\relax
  \advance\dimen0 by #1\relax
  \edef\cals@rs@sofar@length{\the\dimen0}%
  \let\cals@rs@sofar@borderr=#3%
 \else
  \cals@rs@sofar@out
  \let\cals@rs@sofar@length=#1%
  \let\cals@rs@sofar@borderl=#2%
  \let\cals@rs@sofar@borderr=#3%
  \let\cals@rs@sofar@width=#4%
 \fi
\fi}

\newcommand\cals@rs@sofar@over[4]{%
\ifdim 0pt=#4
  \relax
\else
  \ifdim \cals@rs@sofar@width=#4\relax
    \ifdim #3>\cals@rs@sofar@borderr\relax
      \edef\cals@rs@sofar@borderr{#3}%
    \fi
    \dimen0=\cals@rs@sofar@length
    \advance\dimen0 by \cals@rs@sofar@borderl\relax
    \advance\dimen0 by -#2\relax
    \ifdim #1>\dimen0 \relax
      \edef\cals@rs@sofar@borderl{#2}%
    \fi
  \else
    \cals@rs@sofar@out
    \hskip-#1\relax
    \let\cals@rs@sofar@length=#1%
    \let\cals@rs@sofar@borderl=#2%
    \let\cals@rs@sofar@borderr=#3%
    \let\cals@rs@sofar@width=#4%
  \fi
\fi}

\newcommand\cals@rs@sofar@out{%
\ifdim 0pt=\cals@rs@sofar@width\relax
  \hskip\cals@rs@sofar@length\relax
\else
  \cals@halfWidthToDimen0\cals@rs@sofar@borderl
  \hskip-\dimen0\relax
  \cals@halfWidthToDimen2\cals@rs@sofar@borderr
  \dimen4=\cals@rs@sofar@length\relax
  \advance\dimen4 by \dimen0\relax \advance\dimen4 by \dimen2\relax
  \cals@halfWidthToDimen6\cals@rs@sofar@width
  \vrule height\dimen6 depth\dimen6 width\dimen4\relax
  \hskip-\dimen2\relax
\fi}


\newcommand\cals@rs@joinTwo[3]{%
\def\next##1{%
\ifx \eol##1\let\next=\relax
\else
  \toks0=\expandafter{##1}%
  \edef\cals@tmpII{\the\toks0}%
  \llt@decons#3%
  \cals@rs@unpack\cals@tmpII\cals@tmpLI \cals@tmpBlI \cals@tmpBrI \cals@tmpWI
  \cals@rs@unpack\llt@car   \cals@tmpLII\cals@tmpBlII\cals@tmpBrII\cals@tmpWII
  \let\cals@tmp=\cals@iftrue
  \cals@maxWidth\cals@tmpWI\cals@tmpWII
  \ifx \relax\cals@width\else \ifdim \cals@width=0pt %
    \cals@rs@sofar@next\cals@tmpLI\cals@tmpBlI\cals@tmpBrI\cals@width
    \let\cals@tmp=\cals@iffalse
  \fi\fi
  \cals@tmp\ifvoid
    \cals@widthII#1\cals@tmpWI
    \cals@rs@sofar@next\cals@tmpLI\cals@tmpBlI\cals@tmpBrI\cals@width
    \cals@widthII#1\cals@tmpWII
    \cals@rs@sofar@over\cals@tmpLII\cals@tmpBlII\cals@tmpBrII\cals@width
  \fi
\fi
\next}%
\expandafter\next#2\eol}

\newcommand\cals@rs@joinOne[2]{%
\def\next##1{\ifx\eol##1\let\next=\relax\else
 \toks0=\expandafter{##1}%
 \edef\cals@tmpII{\the\toks0}%
 \cals@rs@unpack\cals@tmpII\cals@tmpL\cals@tmpBl\cals@tmpBr\cals@tmpW
 \cals@widthII#1\cals@tmpW
 \cals@rs@sofar@next\cals@tmpL\cals@tmpBl\cals@tmpBr\cals@width
\fi\next}%
\expandafter\next#2\eol}

\def\next{%
  \let\if@RTL=\iffalse
  \let\if@RTLtab=\iffalse
  \let\@RTLtabtrue=\relax
}
\ifdefined\if@RTL \relax \else \next \fi

\newcommand\cals@setup@alignment[1]{%
\if c#1\relax \cals@vfillAdd \leftskip \cals@vfillAdd \rightskip \fi
\if@RTL
 \if l#1\relax \cals@vfillAdd \leftskip \cals@vfillDrop\rightskip \fi
 \if r#1\relax \cals@vfillDrop\leftskip \cals@vfillDrop\rightskip \fi
\else
 \if l#1\relax \cals@vfillDrop\leftskip \cals@vfillDrop\rightskip \fi
 \if r#1\relax \cals@vfillAdd \leftskip \cals@vfillDrop\rightskip \fi
\fi
}

\newcommand\cals@hskip@lr[2]{%
\if@RTL \hskip#2\relax \else \hskip#1\relax \fi}

\endinput
%%
%% End of file `cals.sty'.
