%%% ====================================================================
%%%  @LaTeX-style-file{
%%%     author          = "Enrico Bertolazzi",
%%%     version         = "1.0",
%%%     date            = "13-JUN-2001",
%%%     filename        = "easybmat.sty",
%%%     address         = "Laboratorio di Matematica Applicata
%%%                        e Meccanica Strutturale,
%%%                        Trento University,
%%%                        Via Mesiano, Trento, Italy",
%%%     FAX             = "+39 (461) 882599",
%%%     email           = "enrico.bertolazzi@ing.unitn.it (Internet)",
%%%     supported       = "yes. Please send comments via E-mail",
%%%     docstring       = "package for easy typing block matrices."
%%%
%%% INSTALLATION:
%%%   Put this file where your TeX looks for inputs.
%%%
%%% DOCUMENTATION:
%%%   Compile docbmat.tex.
%%%
%%%   Copyright  1999 Enrico Bertolazzi
%%%
%%%   This program can be redistributed and/or modified under the terms
%%%   of the LaTeX Project Public License Distributed from CTAN
%%%   archives in directory macros/latex/base/lppl.txt; either
%%%   version 1 of the License, or any later version.
%%%
%%%  }
%%% ====================================================================%%%
%%%       ___    ____  ___   _   _         ___    ____  ___   _   _     %%%
%%%      /   \  /     /   \  \  /         /   \  /     /   \  \  /      %%%
%%%     /____/ /__   /____/   \/         /____/ /__   /____/   \/       %%%
%%%    /   \  /     /  \      /         /   \  /     /  \      /        %%%
%%%   /____/ /____ /    \    /         /____/ /____ /    \    /         %%%
%%% ====================================================================%%%
%%% v 1.0 13-JUN-2001 changed \@roman with \romannumeral (thanks to Claudio Beccari) 
\def\filedate{2001/06/13}
\def\fileversion{v1.0}
\typeout{Document Style `easybmat'  \fileversion\space<\filedate>.}
%% BEGIN easybmat.sty
%%

\NeedsTeXFormat{LaTeX2e}
\RequirePackage{easy}
\ProvidesPackage{easybmat}[\filedate\space\fileversion]

\DeclareOption{thinlines}{%
   \@bmat@size@rule=.7pt\relax
   \@bmat@size@dash=.5pt\relax
}

\DeclareOption{thiklines}{%
   \@bmat@size@rule=1.5pt\relax
   \@bmat@size@dash=1.2pt\relax
}

\DeclareOption{thicklines}{%
   \@bmat@size@rule=1.5pt\relax
   \@bmat@size@dash=1.2pt\relax
}

\newdimen\@bmat@size@rule\@bmat@size@rule=1pt\relax
\newdimen\@bmat@size@dash\@bmat@size@dash=.7pt\relax

\ProcessOptions

\@easy@disable@space

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\def\@bmat@addcol{\g@addto@macro\@bmat@preamble{$\displaystyle{##}$&}}
\def\@bmat@make@preamble{%
   \@easy@let(@easy@align){@easy@col@align\romannumeral\@easy@level}%
   \@easy@let(@easy@rules){@easy@col@rules\romannumeral\@easy@level}%
   \gdef\@bmat@preamble{%
       \vbox\bgroup\lineskip\z@skip%
                   \tabskip\z@skip%
                   \baselineskip\z@skip%
                   \everycr{}\halign\bgroup}%
   \@easy@rotate\@easy@align%
   \loop%
      \@easy@rotate\@easy@align%
      \edef\@tempa{\@easy@firstchar\@easy@align}%
   \expandafter\ifx\@tempa`\relax\else%
      \@bmat@addcol%
   \repeat%
   \g@addto@macro\@bmat@preamble{$\displaystyle{##}$\crcr}
}


\def\BMAT{\advance\@easy@level\@ne\@easy@ifnextchar({\@BMAT}{\@BMAT(@)}}
\def\@BMAT(#1){
    \def\@bmat@split##1,##2,##3,##4\end{
       \@easy@xdef(@bmat@balance\romannumeral\@easy@level){##1}%
       \global\@nameuse{@easy@minx\romannumeral\@easy@level}=##2
       \global\@nameuse{@easy@miny\romannumeral\@easy@level}=##3
    }
    \expandafter\@bmat@split#1,\z@,\z@, \end
    \@@BMAT}
    
\def\@@BMAT{\@easy@ifnextchar[{\@@@BMAT}{\@@@BMAT[2pt]}}

\def\@@@BMAT[#1]#2#3{
    \def\@bmat@split##1,##2,##3,##4\end{
       \@easy@xdef(@bmat@spread\romannumeral\@easy@level){##1}%
       \global\@nameuse{@easy@maxx\romannumeral\@easy@level}=##2
       \global\@nameuse{@easy@maxy\romannumeral\@easy@level}=##3
    }
    \expandafter\@bmat@split#1,\z@,\z@, \end
	\@easy@parse@cols{#2}
	\@easy@parse@rows{#3}%
	\@bmat@make@preamble%
    \def\\{\crcr}%
    \global\let\@easy@path\@empty%
 	\setbox\@nameuse{@easy@box\romannumeral\@easy@level}\@bmat@preamble%
}
\def\endBMAT{%
	\crcr\egroup\egroup%
    \@easy@glet(@easy@mainbox)   {@easy@box\romannumeral\@easy@level}%
    \@easy@glet(@easy@col@align) {@easy@col@align\romannumeral\@easy@level}%
    \@easy@glet(@easy@col@rules) {@easy@col@rules\romannumeral\@easy@level}%
    \@easy@glet(@easy@row@align) {@easy@row@align\romannumeral\@easy@level}%
    \@easy@glet(@easy@row@rules) {@easy@row@rules\romannumeral\@easy@level}%
    \@easy@glet(@easy@minx)      {@easy@minx\romannumeral\@easy@level}%
    \@easy@glet(@easy@miny)      {@easy@miny\romannumeral\@easy@level}%
    \@easy@glet(@easy@maxx)      {@easy@maxx\romannumeral\@easy@level}%
    \@easy@glet(@easy@maxy)      {@easy@maxy\romannumeral\@easy@level}%
    %
    \@easy@glet(@easy@balance)   {@bmat@balance\romannumeral\@easy@level}%
    \@easy@glet(@easy@spread)    {@bmat@spread\romannumeral\@easy@level}%
    %
    \global\let\@easy@size@dash\@bmat@size@dash
    \global\let\@easy@size@rule\@bmat@size@rule
    %
    \@easy@evaldim%
%     \typeout{Easybmat [row:\the\@easy@nrow,col:\the\@easy@ncol]}
    \@easy@balance@row@col%
    \@easy@buildbox%
    \@easy@vlines%
    \@easy@hlines%
	\vcenter{\hbox{\rlap{\box\@ne}
	               \rlap{\box\tw@}
	               \ifx\@easy@path\@empty\else\@easy@dopath\rlap{\box\thr@@}\fi
	               \box\@easy@mainbox}}%
    \advance\@easy@level\m@ne%
}

\@easy@enable@space

\endinput
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%