% \iffalse
%
%    makecell.dtx - Managing of tabular column heads and cells.
%    (c) 2005--2007 Olga Lapko (Lapko.O@g23.relcom.ru)
%
%    This program is provided under the terms of the
%    LaTeX Project Public License distributed from CTAN
%    archives in directory macros/latex/base/lppl.txt.
%
% \fi
%
% \iffalse
%<*driver>
\ProvidesFile{makecell.dtx}
%</driver>
%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<package>\ProvidesPackage{makecell}
%<*package>
    [2009/08/03 V0.1e Managing of Tab Column Heads and Cells]
%</package>
%
%<*batchfile>
\begingroup

\input docstrip.tex

\keepsilent
\askforoverwritefalse

\generate{\file{makecell.sty}{\from{makecell.dtx}{package}}}

\endgroup
%</batchfile>
%
%<*driver>
\documentclass{ltxdoc}
\IfFileExists{rotating.sty}{\usepackage{rotating}}{}
\IfFileExists{footmisc.sty}{\usepackage[perpage,bottom]{footmisc}}{}
\IfFileExists{multirow.sty}{\usepackage{multirow}}{}
\IfFileExists{hyperref.sty}{\usepackage{hyperref}}{}
\IfFileExists{hypcap.sty}{\usepackage{hypcap}}{}
\usepackage{makecell}
\IfFileExists{caption.sty}
  {\usepackage[font=small,labelfont=bf,labelsep=period]{caption}[2004/11/28]
  \IfFileExists{floatrow.sty}
  {\usepackage[font=small,style=plaintop,captionskip=5pt]{floatrow}}
  {}}{}
\makeatletter
\@ifundefined{ttabbox}{\let\ttabbox\relax}{}
\makeatother
\usepackage{tabularx}
\usepackage{slashbox}
\usepackage{hhline}
\EnableCrossrefs
\CodelineIndex
\RecordChanges
\makeatletter
\@beginparpenalty10000
\widowpenalty10000
\clubpenalty10000
\makeatother
\providecommand*{\file}[1]{\texttt{#1}}
\providecommand*{\package}[1]{\textsf{#1}}
\providecommand*{\cls}[1]{\textsf{#1}}
\providecommand*{\env}[1]{\texttt{#1}}

%\OnlyDescription
\begin{document}
  \DocInput{makecell.dtx}
  \PrintChanges
\end{document}
%</driver>
% \fi
%
% \CheckSum{1407}
%
% \GetFileInfo{makecell.dtx}
%
% \DoNotIndex{\newcommand,\newenvironment}
%
%
% \title{The \textsf{makecell} package\thanks{This
%          file has version number \fileversion,
%          last revised \filedate.}}
%   \author{%
%   Olga Lapko\\
%   {\tt Lapko.O@g23.relcom.ru} }
%   \date{\filedate}
%   \maketitle
%   \begin{abstract}
%   This package helps to create common layout for tabular material.
%   The |\thead| command, based on one-column tabular environment, is offered
%   for creation of tabular column heads. This macro allows to support common
%   layout for tabular column heads in whole documentation. Another command,
%   |\makecell|, is offered for creation of multilined tabular cells.
%   There are also command |\makecellbox| command and |mcellbox| environment
%   usage of tabular cells inside text.
%
%   Package also offers: \quad 1)\nobreak\enskip macro |\makegapedcells|,
%   which changes vertical spaces around all cells in tabular, like in
%   \package{tabls} package, but uses code of \package{array} package. (Macro
%   |\makegapedcells| redefines macro |\@classz| from \package{array} package.
%   Macro |\nomakegapedcells| cancels this redefinition.);
%   \quad 2)\nobreak\enskip macros |\multirowhead| and |\multirowcell|,
%   which use |\multirow| macro from \package{multirow} package;
%   \quad 3)\nobreak\enskip numbered rows |\nline| or skipping cells |\eline|
%   in tabulars; also are the skipping rows command |\erows| and
%   repeated rows command |\Xrows|;
%   \quad 4)\nobreak\enskip diagonally divided cells (|\diaghead|)
%   plus citation of sample file of \package{slashbox} package, which does the same;
%   \quad 5)\nobreak\enskip |\hline|  and |\cline| with defined thickness:
%    |\Xhline|  and |\Xcline| consequently.
%   \smallskip
%
%   \end{abstract}
%
% \clearpage
% \tableofcontents
%
% \clearpage
% \section{Tabular Cells and Column Heads}
%
% \subsection{Building Commands}
%
% \DescribeMacro{\makecell}
% Macro creates one-column tabular with predefined common settings of
% alignment, spacing and vertical spaces around (see section~\ref{sec:sets}).
% This will be useful for creation of multilined cells. This macro allows
% optional alignment settings.
% \begin{quote}
% |\makecell|\oarg{vertical or/and horizontal alignment}\marg{cell text}
% \end{quote}
% For vertical alignment you use \texttt{t}, \texttt{b}, or \texttt{c}---%^^A
% this letters you usually put in optional argument of \env{tabular} or
% \texttt{array} environments. For horizontal alignment you may use alignment
% settings like \texttt{r}, \texttt{l}, or \texttt{c}, or more complex, like
% |{p{3cm}}|. Since this package loads \package{array} package, you may
% use such alignment settings like |{>{\parindent1cm}p{3cm}}|.
%\begin{verbatim}
%\begin{tabular}{|c|c|}
%\hline
%Cell text & 28--31\\
%\hline
%\makecell{Multilined \\ cell text} & 28--31\\
%\hline
%\makecell[l]{Left aligned \\ cell text} & 37--43\\
%\hline
%\makecell*[r]{Right aligned \\ cell text} & 37--43\\
%\hline
%\makecell[b]{Bottom aligned \\ cell text} & 52--58\\
%\hline
%\makecell*[{{p{3cm}}}]{Cell long text with predefined width} & 52--58\\
%\hline
%\makecell[{{>{\parindent1em}p{3cm}}}]{Cell long...} & 52--58\\
%\hline
%\end{tabular}
%\end{verbatim}
% \begin{table}[h]
% \ttabbox
% {\caption{Example of multilined cells}\label{tab:cells}}%
% {\begin{tabular}{|c|c|}
% \hline
% Cell text & 28--31\\
% \hline
% \makecell{Multilined \\ cell text} & 28--31\\
% \hline
% \makecell[l]{Left aligned \\ cell text} & 37--43\\
% \hline
% \makecell*[r]{Right aligned \\ cell text} & 37--43\\
% \hline
% \makecell[b]{Bottom aligned\\ cell text} & 52--58\\
% \hline
% \makecell*[{{p{3cm}}}]{Cell long text with predefined width} & 52--58\\
% \hline
% \makecell[{{>{\parindent1em}p{3cm}}}]{Cell long text with predefined width} &
%    52--58\\
% \hline
% \end{tabular}}
% \end{table}
%
% Starred form of command, |\makecell*|, creates vertical |\jot| spaces
% around.
%
% \emph{Note}. When you define column alignment like |{p{3cm}}| in optional
% argument of |\makecell| (or |\thead|, see below), please follow these
% rules: \quad 1)\nobreak\enskip if vertical
% alignment defined, write column alignment in group, e.g. |[c{p{3cm}}]|;
% \quad 2)\nobreak\enskip if vertical alignment is absent,
% write column alignment in double
% group---|[{{p{3cm}}}]|, or add empty group---|[{}{p{3cm}}]|. Be also
% careful with vertical alignment when you define column alignment as
% paragraph block: e.g., use |{{b{3cm}}}| for bottom alignment (and
% |{{m{3cm}}}| for centered vertical alignment).
%
% \DescribeMacro{\thead}
% Macro creates one-column \texttt{tabular} for column heads with predefined
% common settings (see table~\ref{tab:thead}). This macro uses common layout
% for column heads: font, alignment, spacing, and vertical spaces around
% (see section~\ref{sec:tsets}).
%\begin{verbatim}
%\renewcommand\theadset{\def\arraystretch{.85}}%
%\begin{tabular}{|l|c|}
%\hline
%\thead{First column head}&
%  \thead{Second \\multlined \\ column head}\\
%\hline
%Left column text & 28--31\\
%\hline
%\end{tabular}
%\end{verbatim}
% \begin{table}[h]
% \ttabbox
% {\caption{Example of column heads}\label{tab:thead}}
% {\renewcommand\theadset{\def\arraystretch{.85}}
% \begin{tabular}{|l|c|}
% \hline
% \thead{First column head}&
%   \thead{Second \\multlined \\ column head}\\
% \hline
% Long left column text & 28--31\\
% \hline
% \end{tabular}}
% \end{table}
%
% Starred form of command, |\thead*|, creates vertical |\jot| spaces around.
%
% \DescribeMacro{\rothead}
% Creates table heads rotated by 90$^\circ$ counterclockwise.
% Macro uses the same font and spacing settings as previous
% one, but column alignment changed to |p{\rotheadsize}| with |\raggedright|
% justification: in this case left side of all text lines ``lies''
% on one base line.
%
% \DescribeMacro{\rotheadsize}
% This parameter defines the width of rotated tabular heads. You may define
% that like:
% \begin{quote}
% |\setlength\rotheadsize{3cm}|
% \end{quote}
% or
% \begin{quote}
% |\settowidth\rotheadsize{\theadfont |\meta{Widest head text}|}|
% \end{quote}
% like in following example (table~\ref{tab:rotheads}):
%\begin{verbatim}
%\settowidth\rotheadsize{\theadfont Second multilined}
%\begin{tabular}{|l|c|}
%\hline
%\thead{First column head}&
%  \rothead{Second multilined \\ column head}\\
%\hline
%Left column text & 28--31\\
%\hline
%\end{tabular}
%\end{verbatim}
% \begin{table}[h]
% \ttabbox
% {\caption{Example of rotated column heads}\label{tab:rotheads}}%^^A%
% {\settowidth\rotheadsize{\theadfont Second multilined}%^^A
% \begin{tabular}{l|l}
% \hline
% \thead{First column head}&
%   \rothead{Second multilined \\ column head}\\
% \hline
% Long left column text & 28--31\\
% \hline
% \end{tabular}}
% \end{table}
%
% \subsection{Settings For Tabular Cells}\label{sec:sets}
%
% This section describes macros, which make layout tuning for multilined
% cells, created by |\makecell| macro (and also |\multirowcell| and
% |\rotcell| macros). The |\cellset| macro also is used by |\thead|
% (|\rothead|, |\multirowtead|) macro.
%
% \DescribeMacro{\cellset}
% Spacing settings for cells. Here you could use commands like:
% \begin{quote}
% |\renewcommand\cellset{\renewcommand\arraytretch{1}%|\\
% |    \setlength\extrarowheight{0pt}}|
% \end{quote}
% as was defined in current package.
%
% \DescribeMacro{\cellalign}
% Default align for cells. Package offers vertical and horizontal centering
% alignment, it defined like:
% \begin{quote}
% |\renewcommand\cellalign{cc}|
% \end{quote}
%
% \DescribeMacro{\cellgape}
% Define vertical spaces around |\makecell|, using |\gape| command if
% necessary. It defined like:
% \begin{quote}
% |\renewcommand\cellgape{}|
% \end{quote}
% You may define this command like
% \begin{quote}
% |\renewcommand\cellgape{\Gape[1pt]}|
% \end{quote}
% or
% \begin{quote}
% |\renewcommand\cellgape{\gape[t]}|
% \end{quote}
% (See also section~\ref{sec:gape} about |\gape| and |\Gape| command.)
%
% \DescribeMacro{\cellrotangle}
% The angle for rotated cells and column heads. The default value 90
% (counterclockwise). This value definition is used by both |\rotcell| and
% |\rothead| macros.
%
% \subsection{Settings For Column Heads}\label{sec:tsets}
%
% This section describes macros, which make layout tuning for tabular column
% heads, created by |\thead| (|\rothead|, |\multirowtead|) macro.
%
% \DescribeMacro{\theadfont}
% Sets a special font for column heads. It could be smaller size
% \begin{quote}
% |\renewcommand\theadfont{\foonotesize}|
% \end{quote}
% as was defined in current package (here we suppose that
% \verb|\small| command used for tabular contents itself).
% Next example defines italic shape
% \begin{quote}
% |\renewcommand\theadfont{\itshape}|
% \end{quote}
%
% \DescribeMacro{\theadset}
% Spacing settings for column heads. Here you could use commands like:
% \begin{quote}
% |\renewcommand\theadset{\renewcommand\arraytretch{1}%|\\
% |    \setlength\extrarowheight{0pt}}|
% \end{quote}
%
% \DescribeMacro{\theadalign}
% Default align for tabular column heads. Here also offered centering
% alignment:
% \begin{quote}
% |\renewcommand\theadalign{cc}|
% \end{quote}
%
% \DescribeMacro{\theadgape}
% Define vertical spaces around column head (|\thead|),
% using |\gape| command if necessary.
% It defined like:
% \begin{quote}
% |\renewcommand\theadgape{\gape}|
% \end{quote}
%
% \DescribeMacro{\rotheadgape}
% Analogous definition for rotated column heads. Default is absent:
% \begin{quote}
% |\renewcommand\rotheadgape{}|
% \end{quote}
%
% \clearpage
% \section{Changing of Height and Depth of Boxes}\label{sec:gape}
%
% Sometimes \env{tabular} or \env{array} cells, or some elements in text need a
% height/depth correction. The |\raisebox| command could help for it, but
% usage of that macro in these cases, especially inside math, is rather
% complex. Current package offers the |\gape| macro, which usage is similar
% to |\smash| macro. The |\gape| macro allows to change height and/or depth
% of included box with necessary dimension.
%
% \DescribeMacro{\gape}
% This macro changes included box by |\jot| value (usually 3\,pt). It is
% defined with optional and mandatory arguments, like |\smash| macro, which
% (re)defined by \package{amsmath} package. Optional argument sets change of
% height only (\texttt{t}) or depth only~(\texttt{b}). Mandatory argument
% includes text.
%   \begin{quote}
%   |\gape|\oarg{\texttt{t} or \texttt{b}}\marg{text}
%   \end{quote}
% Examples of usage:
% \begin{quote}
% \noindent
% \vbox{\halign{#\cr
% \noalign{\hrule}
% \gape{\cmd{\gape}\texttt{\{text\}}}\cr
% \noalign{\hrule}
% \crcr}}\qquad
% \vbox{\halign{#\cr
% \noalign{\hrule}
% \gape[t]{\cmd{\gape}\texttt{[t]\{text\}}}\cr
% \noalign{\hrule\vskip\jot}
% \crcr}}\qquad
% \vbox{\halign{#\cr
% \noalign{\hrule}
% \gape[b]{\cmd{\gape}\texttt{[b]\{text\}}}\cr
% \noalign{\hrule}
% \crcr}}
% \end{quote}
%
% \DescribeMacro{\Gape}
% Another way of height/depth modification. This macro allows different
% correction for height and depth of box:
%   \begin{quote}
%   |\Gape|\oarg{height corr}\oarg{depth corr}\marg{text}
%   \end{quote}
%
% If both arguments absent, |\Gape| command works like |\gape|\marg{text}, in
% other words, command uses |\jot| as correction value for height and depth
% of box.
%
% If only one optional argument exists, |\Gape| command uses value
% from this argument for both height and depth box corrections.
% \begin{quote}
% \noindent
% \vbox{\halign{#\cr
% \noalign{\hrule}
% \Gape{\cmd{\Gape}\texttt{\{text\}}}\cr
% \noalign{\hrule}
% \crcr}}\texttt{\phantom{xxxxx}}\qquad
% \vbox{\halign{#\cr
% \noalign{\hrule}
% \Gape[\jot]{\cmd{\Gape}\texttt{[\cmd{\jot}]\{text\}}}\cr
% \noalign{\hrule}
% \crcr}}\\[2ex]
% \vbox{\halign{#\cr
% \noalign{\hrule}
% \Gape[6pt]{\cmd{\Gape}\texttt{[6pt]\{text\}}}\cr
% \noalign{\hrule}
% \crcr}}\qquad
% \vbox{\halign{#\cr
% \noalign{\hrule}
% \Gape[6pt][-2pt]{\cmd{\Gape}\texttt{[6pt][-2pt]\{text\}}}\cr
% \noalign{\hrule\vskip8pt}
% \crcr}}
% \end{quote}
%
% You may also use |\height| and |\depth| parameters in optional arguments
% of |\Gape| macro, parameters was borrowed from |\raisebox| command.
%
% \DescribeMacro{\bottopstrut}
% \DescribeMacro{\topstrut}
% \DescribeMacro{\botstrut}
% These three macros modify standard |\strut| by |\jot| value:
%     |\bottopstrut| changes both height and depth;
%     \nopagebreak|\topstrut| changes only height;
%     |\botstrut| changes only depth.
%  These commands could be useful, for example, in first and last table rows.
%
%  \emph{Note}. If you use
%  \package{bigstrut} package note that these macros duplicate \cmd{\bigstrut},
%  \cmd{\bigstrut[t]}, and \cmd{\bigstrut[b]} commands consequently. Please
%  note that value, which increases strut in \cmd{\topstrut} etc. equals to
%  \cmd{\jot}, but \cmd{\bigstrut} and others use a special dimension
%  \cmd{\bigstrutjot}.
%
% \clearpage
% \section{How to Change Vertical Spaces Around Cells
%  in Whole Table}\label{sec:beta}
%
% This section describes macros which try to emulate one of possibilities of
% \package{tabls} package: to get necessary vertical spacing around cells.
%
% \DescribeMacro{\setcellgapes}
% Sets the parameters for vertical spaces:
% \begin{quote}
% |\setcellgapes|\oarg{\texttt{t} or \texttt{b}}\marg{value}
% \end{quote}
% The  next examples with array and tabular use following settings:
% \begin{quote}
% |\setcellgapes{5pt}|
% \end{quote}
% You may also try to load negative values if you wish. This macro you may
% put in the preamble as common settings.
%
% \DescribeMacro{\makegapedcells}
% \DescribeMacro{\nomakegapedcells}
% The first macro switches on vertical spacing settings. The second cancels
% first~one.
%
% The \cmd{\makegapedcells} macro temporarily redefines macro
% |\@classz| of \package{array} package, so use this mechanism carefully.
% Load |\makegapedcells| inside group or inside environment
% (see table~\ref{tab:gaped}):
%\begin{verbatim}
%\begin{table}[h]
%\makegapedcells
%...
%\end{table}
%\end{verbatim}
% \setcellgapes{5pt}
% \begin{table}
% \makegapedcells
% \ttabbox
% {\caption{Example of multilined cells with additional vertical spaces}%^^A
%  \label{tab:gaped}}%
% {\begin{tabular}{|c|c|}
% \hline
% Cell text & 28--31\\
% \hline
% \makecell{Multilined \\ cell text} & 28--31\\
% \hline
% \makecell[l]{Left aligned \\ cell text} & 37--43\\
% \hline
% \makecell*[r]{Right aligned \\ cell text} & 37--43\\
% \hline
% \makecell[b]{Bottom aligned \\ cell text} & 52--58\\
% \hline
% \makecell*[{{p{3cm}}}]{Cell long text with predefined width} & 52--58\\
% \hline
% \makecell[{{>{\parindent1em}p{3cm}}}]{Cell long  text with
%   predefined width} & 52--58\\
% \hline
% \end{tabular}}
% \end{table}
%
% Please note that space defined in |\setcellgapes| and space which creates
% |\gape|  mechanism in commands
% for tabular cells (usually |\thead| or |\makecell*|) are summarized.
%
% \clearpage
% \section{Multirow Table Heads and Cells}
%
% The next examples show usage of macros which use |\multirow| command from
% \package{multirow} package.\nopagebreak
%
% At first goes short repetition of arguments of |\multirow| macro itself:
% \begin{quote}
% |\multirow|\marg{nrow}\oarg{njot}\marg{width}\oarg{vmove}\marg{contents}
% \end{quote}
% \marg{nrow} sets number of rows (i.e. text lines);
% \oarg{njot} is mainly used if you've used \package{bigstrut} package: it makes
%       additional tuning of vertical position (see comments in
%       \package{multirow} package);
% \marg{width} defines width of contents, the |*| sign used to indicate that
%       the text argument's natural width is to be used;
% \oarg{vmove} is a length used for fine tuning: the text will be raised (or
%       lowered, if \meta{vmove} is negative) by that length;
% \marg{contents} includes ``|\multirow|'ed'' text.\smallskip
%
% \DescribeMacro{\multirowcell}
% \DescribeMacro{\multirowthead}
% These two macros use following arguments (example uses |\multirowcell|
% command):
% \begin{quote}
% |\multirowcell|\marg{nrow}\oarg{vmove}\oarg{hor alignment}\marg{contents}
% \end{quote}
% in these macros were skipped \oarg{njot} and \marg{width}. Instead of
% tuning optional argument \oarg{njot} for vertical
% correction used \oarg{vmove} optional argument.
% For the \marg{width} argument both |\multirowcell| and |\multirowthead|
% macros use natural width of contents (i.e. the |*| argument used).
%
% First example (table~\ref{tab:mrowI}) with ``|\multirow|'ed'' column heads
% and cells:
%\begin{verbatim}
%\renewcommand\theadset{\def\arraystretch{.85}}%
%\begin{tabular}{|l|c|c|}
% \multirowthead{4}{First ...}&
% \multicolumn{2}{c|}{\thead{Multicolumn head}}\\                 \cline{2-3}
%   & \thead{Second ...} & \thead{Third ...}\\                    \hline
% Cell text & A &\multirowcell{3}{28--31}\\                       \cline{1-2}
% \makecell{Multilined\\Cell text} & B& \\                        \hline
% \makecell[l]{Left ...} & C & \multirowcell{4}[1ex][l]{37--43}\\ \cline{1-2}
% \makecell[r]{Right ...} & D & \\                                \hline
% \makecell[b]{Bottom ...} & E & \multirowcell{5}[1ex][r]{37--43\\52--58}\\
% \cline{1-2}
% \makecell[{{p{5cm}}}]{Cell ...} & F & \\                        \cline{1-2}
% \makecell[{{>{\parindent1em}p{5cm}}}]{Cell ...} & G & \\        \hline
% \end{tabular}
%\end{verbatim}
%
% \begin{table}[p]
%\renewcommand\theadset{\def\arraystretch{.85}}%
% \ttabbox
% {\caption{Example of ``\cmd{\multirow}'ed'' cells}\label{tab:mrowI}}%
% {\begin{tabular}{|l|c|c|}
% \hline
% \multirowthead{4}{First Column head}&
% \multicolumn{2}{c|}{\thead{Multicolumn head}}\\
% \cline{2-3}
%  & \thead{Second \\multlined \\ column head} &
%   \thead{Third \\ column head}\\
% \hline
% Cell text & A &\multirowcell{3}{28--31}\\
% \cline{1-2}
% \makecell{Multilined\\Cell text} & B& \\
% \hline
% \makecell[l]{Left aligned\\ cell text} & C
%                          & \multirowcell{4}[1ex][l]{37--43}\\
% \cline{1-2}
% \makecell[r]{Right aligned\\ cell text} & D & \\
% \hline
% \makecell[b]{Bottom aligned\\ cell text} & E &
%   \multirowcell{5}[1ex][r]{37--43\\52--58}\\
% \cline{1-2}
% \makecell[{{p{5cm}}}]{Cell long long long long text with predefined width}
%                      & F & \\
% \cline{1-2}
% \makecell[{{>{\parindent1em}p{5cm}}}]{Cell long long long long text with
%    predefined width} & G & \\
% \hline
% \end{tabular}}
% \end{table}
%
% Second example (table~\ref{tab:mrowII}) with ``multirow'ed'' column heads
% and cells uses |\makegapedcells| command. The |\theadgape| command does
% nothing:
%\begin{verbatim}
%\makegapedcells
%\renewcommand\theadset{\def\arraystretch{.85}}%
%\renewcommand\theadgape{}
%...
%\end{verbatim}
% \begin{table}[p]\makegapedcells
%\renewcommand\theadset{\def\arraystretch{.85}}%
%\renewcommand\theadgape{}
% \ttabbox
% {\caption{Example of ``\cmd{\multirow}'ed'' cells and additional vertical
%   spaces}\label{tab:mrowII}}%
% {\begin{tabular}{|l|c|c|}
% \hline
% \multirowthead{4}{First Column head}&
% \multicolumn{2}{c|}{\thead{Multicolumn head}}\\
% \cline{2-3}
%  & \thead{Second \\multlined \\ column head} &
%   \thead{Third \\ column head}\\
% \hline
% Cell text & A &\multirowcell{4}{28--31}\\
% \cline{1-2}
% \makecell{Multilined \\Cell text} & B& \\
% \hline
% \makecell[l]{Left aligned \\ cell text} & C
%                          & \multirowcell{4}[0ex][l]{37--43}\\
% \cline{1-2}
% \makecell[r]{Right aligned \\ cell text} & D & \\
% \hline
% \makecell[b]{Bottom aligned \\ cell text} & E &
%   \multirowcell{6}[0ex][r]{37--43\\52--58}\\
% \cline{1-2}
% \makecell[{{p{5cm}}}]{Cell long long long long text with predefined width}
%                      & F & \\
% \cline{1-2}
% \makecell[{{>{\parindent1em}p{5cm}}}]{Cell long long long long text with
%    predefined width} & G & \\
% \hline
% \end{tabular}}
% \end{table}
% \bigskip
%
% The last example (table~\ref{tab:mrowIII}) uses \env{tabularx} environment
% with |\hsize| in the width argument.
%\begin{verbatim}
%\makegapedcells
%\renewcommand\theadset{\def\arraystretch{.85}}%
%\renewcommand\theadgape{}
%\begin{tabularx}\hsize{|X|c|c|}
%...
%\cline{1-2}
%\makecell[{{p{\hsize}}}]{Cell ...} & F & \\
%\cline{1-2}
%\makecell[{{>{\parindent1em}p{\hsize}}}]{Cell ...} & G & \\
%\hline
%\end{tabularx}
%\end{verbatim}
% As you may see the |\makecell|'s in last two rows defined as
% \begin{quote}
% |\makecell[{{p{\hsize}}}]{...}|
% \end{quote}
% and
% \begin{quote}
% |\makecell[{{>{\parindent1em}p{\hsize}}}]{...}|
% \end{quote}
% consequently.
% \begin{table}\makegapedcells
%\renewcommand\theadset{\def\arraystretch{.85}}%
%\renewcommand\theadgape{}
% \ttabbox
% {\caption{Example of \env{tabularx} environment}\label{tab:mrowIII}}%
% {\begin{tabularx}\hsize{|X|c|c|}
% \hline
% \multirowthead{4}{First Column head}&
% \multicolumn{2}{c|}{\thead{Multicolumn head}}\\
% \cline{2-3}
%  & \thead{Second \\multlined \\ column head} &
%   \thead{Third \\ column head}\\
% \hline
% Cell text & A &\multirowcell{4}{28--31}\\
% \cline{1-2}
% \makecell{Multilined \\Cell text} & B& \\
% \hline
% \makecell[l]{Left aligned \\ cell text} & C
%                          & \multirowcell{4}[0ex][l]{37--43}\\
% \cline{1-2}
% \makecell[r]{Right aligned \\ cell text} & D & \\
% \hline
% \makecell[b]{Bottom aligned \\ cell text} & E &
%   \multirowcell{6}[0ex][r]{37--43\\52--58}\\
% \cline{1-2}
% \makecell[{{p{\hsize}}}]{Cell long long long long long long text with
%   predefined width} & F & \\
% \cline{1-2}
% \makecell[{{>{\parindent1em}p{\hsize}}}]{Cell long long long long long
%   long text with predefined width} & G & \\
% \hline
% \end{tabularx}}
% \end{table}
%
% \subsection{Multirow Table Heads and Cells: Second Variant}
%
% Another, simplified, variant of multirow cell: use
% |\makecell| and |\thead| commands, and set |\\| with
% negative space at the end, for example
%\begin{quote}
% |\thead{First Column head\\[-5ex]}|
%\end{quote}
% cells, which stay in one ``multi row'' will have the same value of this
% negative space, in spite of different number of lines in their contents.
%
% \clearpage\suppressfloats[t]
% \section{Numbered Lines in Tabulars}
%
% The three commands |\eline|, |\nline|, |\rnline| allow to skip:
% \begin{quote}
% |\eline|\marg{number of cells}
% \end{quote}
% and numbering (|\nline|) a few/all sells in the row:
% \begin{quote}
% |\nline|\oarg{numbering type}\oarg{start number}\marg{number of cells}
% \end{quote}
% Command |\rnline| does the same as |\nline|, but allows numbering by
% Russian letters (it redefines
% \LaTeX's |\Alph| and |\alph| with |\Asbuk| and |\asbuk| consequently).
% (see table~\ref{tab:elines})
%\begin{verbatim}
%   \begin{tabular}{|*{12}{c|}}
%   \hline
%   \eline{6}                   \\ \hline
%   \nline{6}                   \\ \hline
%   \eline{3} & \nline[1][4]{3} \\ \hline
%   \nline[(a)]{6}              \\ \hline
%   \nline[column I]{6}         \\ \hline
%   \end{tabular}
%\end{verbatim}
%
% \begin{table}[H]
% \ttabbox
% {\caption{Examples of filling of cells}\label{tab:elines}}%
%   {\begin{tabular}{|*{6}{c|}}
%   \hline
%   \eline{6}                   \\ \hline
%   \nline{6}                   \\ \hline
%   \eline{3} & \nline[1][4]{3} \\ \hline
%   \nline[(a)]{6}              \\ \hline
%   \nline[column I]{6}         \\ \hline
%   \end{tabular}}
%\end{table}
%
% Two ``lazy'' commands: for empty table rows
% (|\erows|) and for rows with repeated text (|\Xrows|) were added in the version V0.1e.
%
%\DeleteShortVerb{\|}
%\begin{verbatim}
%   \begin{tabular}{|*{4}{c|}}
%   \hline
%   \thead{No}&\thead{First Data}&\thead{Second Data}&\thead{Third Data} \\
%   \hline
%   \erows{4}{8}
%   \end{tabular}\quad
%   \begin{tabular}{||c||c||c||c||}
%   \hhline{|t:=:t:=:t:=:t:=:t|}
%   \thead{No}&\thead{First Data}&\thead{Second Data}&\thead{Third Data} \\
%   \hhline{|:=::=::=::=:|}
%   \erows[\\ \hhline{|:=::=::=::=:|}]{4}{8}
%   \eline{4}\\ \hhline{|b:=:b:=:b:=:b:=:b|}
%   \end{tabular}\quad
%   \begin{tabular}{|*{4}{c|}}
%   \hline
%   \thead{No}&\thead{First Data}&\thead{Second Data}&\thead{Third Data} \\
%   \hline
%   \Xrows{\refstepcounter{enumi}\arabic{enumi}.\eline{3}\\ \hline}{8}
%   \end{tabular}
%\end{verbatim}
%
% \begin{table}[hbt]\extrarowheight1pt
% \ttabbox[\hsize]
% {\caption{Examples of filling of cells}\label{tab:elines}}%
%   {\begin{tabular}{|*{4}{c|}}
%   \hline
%   \thead{No}&\thead{First Data}&\thead{Second Data}&\thead{Third Data} \\
%   \hline
%   \erows{4}{8}
%   \end{tabular}\par\bigskip
%   \begin{tabular}{||c||c||c||c||}
%   \hhline{|t:*3{=:t:}=:t|}
%   \thead{No}&\thead{First Data}&\thead{Second Data}&\thead{Third Data} \\
%   \hhline{|:*3{=::}=:|}
%   \erows[\\ \hhline{|:*3{=::}=:|}]{4}{7}
%   \eline{4}\\
%   \hhline{|b:*3{=:b:}=:b|}
%   \end{tabular}\par\bigskip
%   \begin{tabular}{|*{4}{c|}}
%   \hline
%   \thead{No}&\thead{First Data}&\thead{Second Data}&\thead{Third Data} \\
%   \hline
%   \Xrows{\refstepcounter{enumi}\arabic{enumi}.\eline{4}\\ \hline}{8}
%   \end{tabular}}
%\end{table}
%\MakeShortVerb{\|}
%
% \section{Cells (One-Column Tabulars) in the Text}
%
% If the |\makecell| command appears in the text (outside outer tabular environment)
% it could create wrong layout. The |\makecellbox| command
% and |mcellbox| environment are created for one-column tabulars in the text.
%
% \section{Diagonally Divided Cell}
%
% This variant of head's positioning is not too popular nowadays, but in
% the some cases it could be used. Instead of creating of
% multicolumn head above a wide couple of all column heads except the
% very left column, the most left column head (upper left cell)
% divided by diagonal line. The lower head is usually head of very left
% column and upper head---``multicolumn'' to all other column heads of
% table to the right.
%
% This package offers macro based on possibilities of \env{picture}
% environment.
% \begin{quote}
% |\diaghead|\texttt{(}\meta{\texttt{\textup{H}} ratio,%^^A
%       \textup{\texttt{V}} ratio}\texttt{)}%^^A
%   \marg{Text set for column width}|%|\\
%   \phantom{/diaghead }\marg{First head}\marg{Second head}
% \end{quote}
% where \texttt{(}\meta{\textup{\texttt{H ratio}},%^^A
%  \textup{\texttt{V ratio}}}\texttt{)} sets the ratios like in |\line|
% command (digits from~|1| up to~|6|). This argument is optional,
% the default ratio (|\line|
% direction) defined as~|(5,-2)|.
%
% The \marg{Text set for column width}
% defined by hand, for example:
% \quad 1)\nobreak\enskip sets the width, using longest text lines from
% both heads---in this case you must put |\theadfont| macro, if you use
% |\thead|'s; \quad 2)\nobreak\enskip the longest text from the rest of
% column; \quad 3)\nobreak\enskip |\hskip|\meta{value}, even |\hskip\hsize|
% the case of |p| column (or |X| column in \env{tabularx} environment).
% The \marg{First head}
% is head in lower corner (usually for first or very left column),
% \marg{Second head}---in the upper corner (head for the all right columns).
%
% Here is code of table~\ref{tab:diaghead}.
%\begin{verbatim}\makegapedcells
%\begin{tabular}{|l|c|c|}\hline
%\diaghead{\theadfont Diag ColumnmnHead II}%
%       {Diag Column \\Head I}{Diag\\Column Head II}&
%\thead{Second\\column}&\thead{Third\\column}\\
%\hline...
%\end{tabular}\medskip
%
%\begin{tabularx}{.62\hsize}{|X|c|c|}\hline
%\diaghead(-4,1){\hskip\hsize}%
%       {Diag \\Column Head I}{Diag Column \\Head II}&
%\thead{Second\\column}&\thead{Third\\column}\\
%\hline...
%\end{tabularx}\medskip
%
% \nomakegapedcells
% \begin{tabular}{|l|c|c|}\hline
% \diaghead(4,1){\hskip4.2cm}%
%       {Diag \\Column Head I}{Diag Column \\Head II}&
% \thead{Second\\column}&\thead{Third\\column}\\
%...
%\end{verbatim}%
%
% \begin{table}[!bp]\makegapedcells
% \begin{tabular}{|c|c|c|}%
% \hline
% \diaghead{\theadfont Diag ColumnmnHead II}%^^A
%  {Diag \\Column Head I}{Diag Column\\ Head II}&
% \thead{Second\\column}&\thead{Third\\column}\\
% \hline
% \makecell[l]{Left aligned \\ cell text}   & A & 37--43\\
% \hline
% \makecell*[r]{Right aligned \\ cell text} & B & 37--43\\
% \hline
% \makecell[b]{Bottom aligned\\ cell text}  & C & 52--58\\
% \hline
% \end{tabular}%
% \medskip
%
% \begin{tabularx}{.62\hsize}{|X|c|c|}%
% \hline
% \diaghead(4,1){\hskip\hsize}%
% %^^A{\theadfont Diag ColuDiag Column}%^^A
% {Diag \\Column Head I}{Diag Column \\Head II}&
% \thead{Second\\column}&\thead{Third\\column}\\
% \hline
% \makecell[l]{Left aligned \\ cell text}   & A & 37--43\\
% \hline
% \makecell*[r]{Right aligned \\ cell text} & B & 37--43\\
% \hline
% \makecell[b]{Bottom aligned\\ cell text}  & C & 52--58\\
% \hline
% \end{tabularx}%
% \medskip
%
% \nomakegapedcells
% \begin{tabular}{|l|c|c|}%
% \hline
% \diaghead(-4,1){\hskip4.2cm}%^^A
% {Diag \\Column Head I}{Diag Column \\Head II}&
% \thead{Second\\column}&\thead{Third\\column}\\
% \hline
% \makecell[l]{Left aligned \\ cell text}   & A & 37--43\\
% \hline
% \makecell*[r]{Right aligned \\ cell text} & B & 37--43\\
% \hline
% \makecell[b]{Bottom aligned\\ cell text}  & C & 52--58\\
% \hline
% \end{tabular}%
%
% \caption{Examples of tabulars with diagonally divided
% cells}\label{tab:diaghead}
%
% \end{table}%
% The correct position of diagonal ends depends of width of column. If cell width
% is narrower then necessary
% column ends of diagonal don't touch corners of cell.
%
% \section{Comparison: Diagonally Divided Cell with the slashbox package}
%
% I didn't know about the \texttt{slashbox} package in time
% when the code for the diagonal cells was created. This package uses also picture
% |\line| mechanism, but calculates slopes automatically. It creates the
% |\backslash| direction of diagonal lines only. (The |\slash| direction seems to be
% not correct. Or direction depends to traditions of current publishing house?)
%
% Here is used citation of the sample file distributed with the \texttt{slashbox} package%^^A
% \footnote{by Koichi Yasuoka, May 27, 1993; minor modification by Toru Sato, May 31, 1993}.
% The verbatim of the table examples are added only in citation.\smallskip
%
% \begingroup\slshape
% The usage is pretty straightforward, such as
%
%\begin{table}[H]%
%\begin{verbatim}
%\begin{tabular}{|l||*{5}{c|}}\hline
%\backslashbox{Room}{Date}
%&\makebox[3em]{5/31}&\makebox[3em]{6/1}&\makebox[3em]{6/2}
%&\makebox[3em]{6/3}&\makebox[3em]{6/4}\\\hline\hline
%Meeting Room &&&&&\\\hline
%Auditorium &&&&&\\\hline
%Seminar Room &&&&&\\\hline
%\end{tabular}
%\end{verbatim}%
%
% \noindent
% \begin{tabular}{|l||*{5}{c|}}\hline
% \backslashbox{Room}{Date}
% &\makebox[3em]{5/31}&\makebox[3em]{6/1}&\makebox[3em]{6/2}
% &\makebox[3em]{6/3}&\makebox[3em]{6/4}\\\hline\hline
% Meeting Room &&&&&\\\hline
% Auditorium &&&&&\\\hline
% Seminar Room &&&&&\\\hline
% \end{tabular}
%\end{table}%
%
% You may include a newline (\verb+\\+) in `Room' and/or `Date'.
% Note that you will get spaces aside the slash line if there is a
% wider column in the same column of a different line.
% In such a case, you need to specify the width of the slashed column
% by saying
%
%\begin{table}[H]%
%\begin{verbatim}
%\begin{tabular}{|l||*{4}{c|}}\hline
%\backslashbox[48mm]{Room}{Date}
%&\makebox[3em]{5/31}&\makebox[3em]{6/1}&\makebox[3em]{6/2}
%&\makebox[3em]{6/3}\\\hline\hline
%Room With a Long Name &&&&\\\hline
%Auditorium &&&&\\\hline
%Seminar Room &&&&\\\hline
%\end{tabular}
%\end{verbatim}%
%
% \noindent
% \begin{tabular}{|l||*{4}{c|}}\hline
% \backslashbox[48mm]{Room}{Date}
% &\makebox[3em]{5/31}&\makebox[3em]{6/1}&\makebox[3em]{6/2}
% &\makebox[3em]{6/3}\\\hline\hline
% Room With a Long Name &&&&\\\hline
% Auditorium &&&&\\\hline
% Seminar Room &&&&\\\hline
% \end{tabular}
%\end{table}%
%
% \bigskip
% The specified width is neglected if it is narrower than the natural
% width of the column.
%
% \verb+\(back)slashbox+ assumes by default that there is a blank space
% of width \verb+\tabcolsep+ on both sides of the column.
% Thus the slash line might exceeds the boundary when you use \verb+@{}+
% etc.
%
% You can avoid it by specifying
%
%\begin{table}[H]%
%\begin{verbatim}
%\begin{tabular}{|@{\ $\bullet$\hspace*{3mm}}l||*{5}{c|}}\hline
%\multicolumn{1}{|@{}l||}{\backslashbox[0pt][l]{Room}{Date}}
%&\makebox[3em]{5/31}&\makebox[4em]{6/1}&\makebox[3em]{6/2}
%&\makebox[3em]{6/3}&\makebox[3em]{6/4}\\\hline\hline
%Meeting Room &&&&&\\\hline
%Auditorium &&&&&\\\hline
%Seminar Room &&&&&\\\hline
%\end{tabular}
%\end{verbatim}%
%
% \bigskip
%
% \noindent
% \begin{tabular}{|@{\ $\bullet$\hspace*{3mm}}l||*{5}{c|}}\hline
% \multicolumn{1}{|@{}l||}{\backslashbox[0pt][l]{Room}{Date}}
% &\makebox[3em]{5/31}&\makebox[4em]{6/1}&\makebox[3em]{6/2}
% &\makebox[3em]{6/3}&\makebox[3em]{6/4}\\\hline\hline
% Meeting Room &&&&&\\\hline
% Auditorium &&&&&\\\hline
% Seminar Room &&&&&\\\hline
% \end{tabular}
%\end{table}%
%
% Here \verb+[l]+ tells the command that there is no extra space on the
% left of this column.  You can use \verb+[r]+ and \verb+[lr]+ likewise.
% You have to also specify the width of the column in this case, but it
% can be~0pt.
% \endgroup
%
% The addition for the sample with |\slashbox| command. This example demonstrates that you may combine
% the \texttt{makecell} commands and |\backslashbox|.
%
%\begin{table}[H]%
%\begin{verbatim}
%\begin{tabular}{|l||*{5}{c|}}\hline
%\theadset\theadfont\backslashbox{Room}{Date}
%&\makebox[3em]{\thead{5/31}}&\makebox[3em]{\thead{6/1}}&\makebox[3em]{\thead{6/2}}
%&\makebox[3em]{6/3}&\makebox[3em]{\thead{6/4}}\\\hline\hline
%Meeting Room &&&&&\\\hline
%Auditorium &&&&&\\\hline
%Seminar Room &&&&&\\\hline
%\end{tabular}
%\end{verbatim}%
%
% \noindent
% \begin{tabular}{|l||*{5}{c|}}\hline
%\theadset\theadfont\backslashbox{Room}{Date}
%&\makebox[3em]{\thead{5/31}}&\makebox[3em]{\thead{6/1}}&\makebox[3em]{\thead{6/2}}
%&\makebox[3em]{6/3}&\makebox[3em]{\thead{6/4}}\\\hline\hline
% Meeting Room &&&&&\\\hline
% Auditorium &&&&&\\\hline
% Seminar Room &&&&&\\\hline
% \end{tabular}
%\end{table}%
%
%\begin{table}[H]%
%\begin{verbatim}
%\begin{tabular}{|l||*{4}{c|}}\hline
%\theadset\backslashbox[48mm]{Room}{Date}
%&\makebox[3em]{\thead{5/31}}&\makebox[3em]{\thead{6/1}}&\makebox[3em]{\thead{6/2}}
%&\makebox[3em]{\thead{6/3}}\\\hline\hline
%Room With a Long Name &&&&\\\hline
%Auditorium &&&&\\\hline
%Seminar Room &&&&\\\hline
%\end{tabular}
%\end{verbatim}%
%
% \noindent
% \begin{tabular}{|l||*{4}{c|}}\hline
% \theadset\backslashbox[48mm]{Room}{Date}
% &\makebox[3em]{\thead{5/31}}&\makebox[3em]{\thead{6/1}}&\makebox[3em]{\thead{6/2}}
% &\makebox[3em]{\thead{6/3}}\\\hline\hline
% Room With a Long Name &&&&\\\hline
% Auditorium &&&&\\\hline
% Seminar Room &&&&\\\hline
% \end{tabular}
%\end{table}%
%
% \clearpage
% \section{Thick Rules for the hline and cline Commands}
%
% For horizontal rules in tabular there were added two commands
% \cmd{\Xhline} and \cmd{\Xcline}
% They use additional mandatory argument with defined rule width.
%
% The example, with result in table~\ref{tab:XmrowIII}.
%\begin{verbatim}%
%\begin{table}
%\renewcommand\theadset{\def\arraystretch{.85}}%
%\renewcommand\theadgape{}
%\ttabbox
%{\caption{...}\label{...}}%
%{\begin{tabular}{!{\vrule width1.2pt}c
%                 !{\vrule width1.2pt}c|c
%                 !{\vrule width1.2pt}}
%\Xhline{1.2pt}
%\multirowthead{4}{First Column head}&
%\multicolumn{2}{c!{\vrule width1.2pt}}{\thead{Multicolumn head}}\\
%\Xcline{2-3}{1.2pt}
% & \thead{Second \\multlined \\ column head} &
%  \thead{Third \\ column head}\\
%\Xhline{1.2pt}
%Cell text & A &\multirowcell{4}{28--31}\\
%...
%\Xhline{1.2pt}
%\end{tabular}}
%\end{table}
%\end{verbatim}%
%
% \begin{table}\makegapedcells\relax
%\renewcommand\theadset{\def\arraystretch{.85}}%
%\renewcommand\theadgape{}
% \ttabbox
% {\caption{Example of \env{tabular} environment with
%    thick lines}\label{tab:XmrowIII}}%
% {\begin{tabular}{!{\vrule width1.2pt}c
%   !{\vrule width1.2pt}c|c!{\vrule width1.2pt}}
% \Xhline{1.2pt}
% \multirowthead{4}{First Column head}&
% \multicolumn{2}{c!{\vrule width1.2pt}}{\thead{Multicolumn head}}\\
% \Xcline{2-3}{1.2pt}
%  & \thead{Second \\multlined \\ column head} &
%   \thead{Third \\ column head}\\
% \Xhline{1.2pt}
% Cell text & A &\multirowcell{4}{28--31}\\
% \cline{1-2}
% \makecell{Multilined \\Cell text} & B& \\
% \hline
% \makecell[l]{Left aligned \\ cell text} & C
%                          & \multirowcell{4}[0ex][l]{37--43}\\
% \cline{1-2}
% \makecell[r]{Right aligned \\ cell text} & D & \\
% \hline
% \makecell[b]{Bottom aligned \\ cell text} & E &
%   \multirowcell{6}[0ex][r]{37--43\\52--58}\\
% \cline{1-2}
% \makecell[{{p{5cm}}}]{Cell long long long long long long text with
%   predefined width} & F & \\
% \cline{1-2}
% \makecell[{{>{\parindent1em}p{5cm}}}]{Cell long long long long long
%   long text with predefined width} & G & \\
% \Xhline{1.2pt}
% \end{tabular}}
% \end{table}
%
% \StopEventually{}\clearpage
%
% \section{Code of package}
%
% \subsection{Multilined cells}
%
%  First goes request of \package{array} package.
%    \begin{macrocode}
\RequirePackage{array}
%    \end{macrocode}
%
% \begin{macro}{\makecell}
% The definition of command for multilined cells. At first defined |\gape|
% stuff. Non-star form loads special setting for vertical space around (if it
% used). Star form always creates additional vertical |\jot|-spaces.
%    \begin{macrocode}
\newcommand\makecell{\@ifstar{\let\tabg@pe\gape\makecell@}%
                             {\let\tabg@pe\cellgape\makecell@}}
%    \end{macrocode}
% Next macro loads vertical and horizontal common alignment for cells and
% loads redefined spacing parameters |\arraystretch| and |\extrarowheight|
% if these parameters were redefined.
%    \begin{macrocode}
\newcommand\makecell@{\def\t@bset{\cellset}%
   \let\mcell@align\cellalign
   \@ifnextchar[\mcell@tabular
     {\expandafter\mcell@@tabular\cellalign\@nil}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\thead}
% The macro for tabular column heads. At first defined |\gape| stuff.
% Non-star from loads special setting for vertical space around (if it used).
% Star form always creates additional vertical |\jot|-spaces.
%    \begin{macrocode}
\newcommand\thead{\@ifstar{\let\tabg@pe\gape\thead@}%
                          {\let\tabg@pe\theadgape\thead@}}
%    \end{macrocode}
% Next macro loads vertical and horizontal common alignment for column heads
% and loads redefined spacing parameters |\arraystretch| and |\extrarowheight|
% if these parameters were redefined. (First go settings
% for cells, as for |\makecell|, then special settings for column heads.)
%
% For column heads also loaded font settings.
%    \begin{macrocode}
\newcommand\thead@{\def\t@bset{\cellset\theadfont\theadset}%
   \let\mcell@align\theadalign
   \@ifnextchar[\mcell@tabular
     {\expandafter\mcell@@tabular\theadalign\@nil}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\rotheadsize}
% The width dimension for rotated cells.
%    \begin{macrocode}
\@ifdefinable\rotheadsize{\newdimen\rotheadsize}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\rotcell}
% The macro for rotated cell. If no \package{rotating} package loaded
% this macro works like |\makecell|.
%    \begin{macrocode}
\newcommand\rotcell{\@ifundefined{turn}%
  {\PackageWarning{makecell}%
     {\string\rotcell\space needs rotating package}%
  \let\tabg@pe\empty\let\t@bset\cellset\makecell@}
  {\@ifnextchar[{\@rotcell}{\@@rotcell}}}
%    \end{macrocode}
% For rotated cell default column setting is similar to |p{\rotheadsize}| (plus
% some additional justification settings)
%    \begin{macrocode}
\@ifdefinable\@rotcell{}
\def\@rotcell[#1]#2{\makecell*{\\[-.65\normalbaselineskip]
  \turn{\cellrotangle}\makecell[#1]{#2}\endturn}}
\newcommand\@@rotcell[1]{\makecell*{\\[-.65\normalbaselineskip]
  \turn{\cellrotangle}\makecell[c{>{\rightskip0explus
    \rotheadsize\hyphenpenalty0\pretolerance-1%
    \noindent\hskip\z@}p{\rotheadsize}
    }]{#1}\endturn}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\rothead}
% The macro for rotated tabular column heads. If no \package{rotating} package
% loaded this macro works like |\thead|.
%    \begin{macrocode}
\newcommand\rothead{\@ifundefined{turn}%
  {\PackageWarning{makecell}{\string\rothead\space
    needs rotating package}%
   \let\tabg@pe\theadgape
   \def\t@bset{\cellset\theadfont\theadset}\thead@}%
  {\let\theadgape\rotheadgape
   \@ifnextchar[{\@rothead}{\@@rothead}}}
%    \end{macrocode}
% For rotated column head default column setting is similar to
% |p{\rotheadsize}| (plus some additional justification settings)
%    \begin{macrocode}
\@ifdefinable\@rothead{}
\def\@rothead[#1]#2{\thead{\\[-.65\normalbaselineskip]
  \turn{\cellrotangle}\thead[#1]{#2@{}}\endturn}}
\newcommand\@@rothead[1]{\thead{\\[-.65\normalbaselineskip]
  \turn{\cellrotangle}\thead[c{>{\rightskip0explus
    \rotheadsize\hyphenpenalty0\pretolerance-1%
    \noindent\hskip\z@}p{\rotheadsize}
    @{}}]{#1}\endturn}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\multirowcell}
% The macro for multirow cells. If no \package{multirow} package loaded
% this macro works like |\makecell|.
%    \begin{macrocode}
\newcommand\multirowcell{\@ifundefined{multirow}%
  {\PackageWarning{makecell}{\string\multirowcell\space
   needs multirow package}}%
  {\let\mcell@multirow\multirow}\mcell@mrowcell@}
%    \end{macrocode}
% These macros define settings for |\multirow| arguments.
%    \begin{macrocode}
\newcommand\mcell@mrowcell@[1]{\@ifnextchar
  [{\mcell@mrowcell@@{#1}}{\mcell@mrowcell@@{#1}[0pt]}}
\@ifdefinable\mcell@mrowcell@@{}
\def\mcell@mrowcell@@#1[#2]{\edef\mcell@nrows{#1}\edef\mcell@fixup{#2}%
   \let\tabg@pe\cellgape\makecell@}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\multirowthead}
% The macro for multirow column heads. If no \package{multirow} package loaded
% this macro works like |\thead|.
%    \begin{macrocode}
\newcommand\multirowthead{\@ifundefined{multirow}%
  {\PackageWarning{makecell}{\string\multirowthead\space
   needs multirow package}}%
  {\let\mcell@multirow\multirow}\mcell@mrowhead@}
%    \end{macrocode}
% These macros define settings for |\multirow| arguments.
%    \begin{macrocode}
\newcommand\mcell@mrowhead@[1]{\@ifnextchar
  [{\mcell@mrowhead@@{#1}}{\mcell@mrowhead@@{#1}[0pt]}}
\@ifdefinable\mcell@mrowhead@@{}
\def\mcell@mrowhead@@#1[#2]{\edef\mcell@nrows{#1}\edef\mcell@fixup{#2}%
   \let\tabg@pe\theadgape\thead@}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\mcell@multirow}
% By default |\mcell@multirow| macro gobbles |\multirow|'s arguments.
%    \begin{macrocode}
\@ifdefinable\mcell@multirow{}
\def\mcell@multirow#1#2[#3]{}%
%    \end{macrocode}
% \end{macro}
%
% Definitions for horizontal and vertical alignments, which use by \env{tabular}
% and \env{array} environments.
%
% For \texttt{l}, \texttt{r}, \texttt{t}, and \texttt{b} alignments commands
% set |c|-argument as vertical or horizontal centering alignment if necessary.
% For \texttt{l} and \texttt{r} alignments also redefined alignment
% settings for |\makecell| (|\thead|) blocks.
%    \begin{macrocode}
\newcommand\mcell@l{\def\mcell@ii{l}\let\mcell@c\mcell@ic
  \global\let\mcell@left\relax}
\newcommand\mcell@r{\def\mcell@ii{r}\let\mcell@c\mcell@ic
  \global\let\mcell@right\relax}
\newcommand\mcell@t{\def\mcell@i{t}\let\mcell@c\mcell@iic}
\newcommand\mcell@b{\def\mcell@i{b}\let\mcell@c\mcell@iic}
\newcommand\mcell@{}
%    \end{macrocode}
% If alone |c|-argument loaded it is used for horizontal alignment.
%    \begin{macrocode}
\newcommand\mcell@c{\def\mcell@ii{c}}
\newcommand\mcell@ic{\def\mcell@i{c}}
\newcommand\mcell@iic{\def\mcell@ii{c}}
%    \end{macrocode}
% Default vertical and horizontal alignment is centered.
%    \begin{macrocode}
\newcommand\mcell@i{c}
\newcommand\mcell@ii{c}
%    \end{macrocode}
%
% Default horizontal alignment of |\makecell| (|\thead|) blocks is centered.
%    \begin{macrocode}
\@ifdefinable\mcell@left{\let\mcell@left\hfill}
\@ifdefinable\mcell@right{\let\mcell@right\hfill}
%    \end{macrocode}
%
% \begin{macro}{\mcell@tabular}
% \begin{macro}{\mcell@@tabular}
% \begin{macro}{\mcell@@@tabular}
% The core macros for tabular building.
%
% Next few macros for sorting of |\makecell| (|\thead|) arguments.
%    \begin{macrocode}
\@ifdefinable\mcell@tabular{}\@ifdefinable\mcell@@tabular{}
\@ifdefinable\mcell@@@tabular{}
\def\mcell@tabular[#1]#2{\mcell@@tabular#1\@nil{#2}}
%    \end{macrocode}
% The code for this macro borrowed from \package{caption} 3.x package (AS).
%    \begin{macrocode}
\newcommand\mcell@ifinlist[2]{%
  \let\next\@secondoftwo
  \edef\mcell@tmp{#1}%
  \@for\mcell@Tmp:={#2}\do{%
    \ifx\mcell@tmp\mcell@Tmp
      \let\next\@firstoftwo
    \fi}\next}
%    \end{macrocode}
%
% The |\mcell@@tabular| macro at first calls |\mcell@setalign| macro for
% sorting of alignment arguments, then calls |\mcell@@@tabular|
% macro, which created tabular cell or column head.
%    \begin{macrocode}
\def\mcell@@tabular#1#2\@nil#3{%
  \expandafter\mcell@setalign\mcell@align\@nil
  \mcell@setalign{#1}{#2}\@nil
  \expandafter\mcell@@@tabular\expandafter\mcell@i\mcell@ii\@nil{#3}}
%    \end{macrocode}
%
% \begin{macro}{\mcell@setalign}
% This macro sorts arguments for vertical and horizontal alignment.
%
% First argument has second check at the end of macro for the case if
% it is |c|-argument.
%    \begin{macrocode}
\@ifdefinable\mcell@setalign{}
\def\mcell@setalign#1#2\@nil{\def\@tempa{#1}\def\@tempc{c}%
%    \end{macrocode}
% Restore default alignment for |\makecell| and |\thead| blocks.
%    \begin{macrocode}
  \global\let\mcell@left\hfill\global\let\mcell@right\hfill
%    \end{macrocode}
% If in optional argument appears alone |c|-argument it defines
% horizontal centering only.
%    \begin{macrocode}
  \def\mcell@c{\def\mcell@ii{c}}%
  \mcell@ifinlist{#1}{l,r,t,b,c,}{\@nameuse{mcell@#1}}%
%    \end{macrocode}
% If argument is not \texttt{l}, \texttt{r}, \texttt{c}, \texttt{t},
% or \texttt{b} it could define horizontal alignment only.
%    \begin{macrocode}
      {\def\mcell@ii{#1}\let\mcell@c\mcell@ic
       \let\mcell@left\relax\let\mcell@right\relax}%
  \mcell@ifinlist{#2}{l,r,t,b,c,}{\@nameuse{mcell@#2}}%
%    \end{macrocode}
% If argument is not \texttt{l}, \texttt{r}, \texttt{c}, \texttt{t},
% or \texttt{b} it could define horizontal alignment only.
%    \begin{macrocode}
      {\def\mcell@ii{#2}\let\mcell@c\mcell@ic
       \let\mcell@left\relax\let\mcell@right\relax}%
%    \end{macrocode}
% Here goes repeated check for first argument, if it is |c|-argument
% we call |\mcell@c| command, which can be now redefined.
%    \begin{macrocode}
  \ifx\@tempa\@tempc\mcell@c\fi
}
%    \end{macrocode}
% \end{macro}
%
% This macro builds tabular itself.
% First (and last) go commands which align |\makecell| and |\thead|
% blocks like \texttt{l}, \texttt{r}, or \texttt{c} (if they loaded).
% Then goes check whether math mode exists.
% The |\mcell@multirow| emulation macro transforms to |\multirow|
% when necessary.
%    \begin{macrocode}
\def\mcell@@@tabular#1#2\@nil#3{%\mcell@mstyle
  \ifdim\parindent<\z@\leavevmode\else\noindent\fi
  \null\mcell@left
      \ifmmode
         \mcell@multirow\mcell@nrows*[\mcell@fixup]{\tabg@pe
          {\hbox{\t@bset$\array[#1]{@{}#2@{}}#3\endarray$}}}%
      \else
         \mcell@multirow\mcell@nrows*[\mcell@fixup]{\tabg@pe
          {\hbox{\t@bset\tabular[#1]{@{}#2@{}}#3\endtabular}}}%
      \fi\mcell@right\null}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{environment}{\mcellbox}
% \begin{macro}{\makecellbox}
%    \begin{macrocode}
\@ifdefinable\mcell@start{}\@ifdefinable\mcell@stop{}
\newcommand\mcellbox[1][c]{%
    \expandafter\mcell@setalign\cellalign\@nil
    \expandafter\mcell@setalign#1\@nil
    \expandafter\mcell@box\expandafter\mcell@i\mcell@ii\@nil}
\@ifdefinable\mcell@box{}
\def\mcell@box#1#2\@nil{%
    \ifdim\parindent<\z@\leavevmode\else\noindent\fi
    \ifmmode\def\mcell@start{$\array}\def\mcell@stop{\endarray$}\else
       \def\mcell@start{\tabular}\def\mcell@stop{\endtabular}\fi
    \hbox\bgroup\cellset\mcell@start[#1]{@{}#2@{}}}%
\def\endmcellbox   {\mcell@stop\egroup}
\newcommand\makecellbox[2][c]{\begin{mcellbox}[#1]#2\end{mcellbox}}
%    \end{macrocode}
% \end{macro}
% \end{environment}
%
% \begin{macro}{\cellset}
% \begin{macro}{\cellgape}
% \begin{macro}{\cellalign}
% \begin{macro}{\cellrotangle}
% \begin{macro}{\theadfont}
% \begin{macro}{\theadset}
% \begin{macro}{\theadgape}
% \begin{macro}{\rotheadgape}
% \begin{macro}{\theadalign}
% The layout macros for tabular building settings.\nopagebreak
%
% Spacing settings for tabular spacing inside cells (like |\arraystretch|
% or |\extrarowheight|).\nopagebreak
%    \begin{macrocode}
\newcommand\cellset{\def\arraystretch{1}\extrarowheight\z@
   \nomakegapedcells}
%    \end{macrocode}
% Vertical space around cells (created by |\gape| stuff).
%    \begin{macrocode}
\newcommand\cellgape{}
%    \end{macrocode}
% Vertical and horizontal alignment of cell text.
%    \begin{macrocode}
\newcommand\cellalign{cc}
%    \end{macrocode}
% Angle for rotated column heads and cells.
%    \begin{macrocode}
\newcommand\cellrotangle{90}
%    \end{macrocode}
%
% Font for column heads
%    \begin{macrocode}
\newcommand\theadfont{\footnotesize}
%    \end{macrocode}
% Special spacing settings for tabular spacing in column heads (like
% |\arraystretch| or/and |\extrarowheight|).
%    \begin{macrocode}
\newcommand\theadset{}
%    \end{macrocode}
% Vertical space around column heads (created by |\gape| stuff).
%    \begin{macrocode}
\newcommand\theadgape{\gape}
%    \end{macrocode}
% Vertical space around rotated column heads.
%    \begin{macrocode}
\newcommand\rotheadgape{}
%    \end{macrocode}
% Vertical and horizontal alignment of column head text.
%    \begin{macrocode}
\newcommand\theadalign{cc}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \subsection{Gape commands}
%
% \begin{macro}{\gape}
% \begin{macro}{\setcellgapes}
% The macro itself. It uses analogous to |\smash| macro from \package{amsmath}
% package.
%    \begin{macrocode}
\@ifdefinable\gape{}
\DeclareRobustCommand\gape{\@ifnextchar[\@gape{\@gape[tb]}}
%    \end{macrocode}
%
% The |\setcellgapes| defines settings used by |\makegapedcells| command.
%
% First goes check for optional argument.
%    \begin{macrocode}
\newcommand\setcellgapes{\@ifnextchar[%]
  {\mcell@setgapes{MB}}{\mcell@setgapes{MB}[tb]}}
%    \end{macrocode}
% Then body of settings.
%    \begin{macrocode}
\@ifdefinable\@setcellgapes{}
\def\mcell@setgapes#1[#2]#3{\expandafter\let\csname
  mcell@#1@\expandafter\endcsname\csname mcell@mb@#2\endcsname
 \@namedef{mcell@#1jot}{#3}%
%    \end{macrocode}
% Negative compensate inside |\makegapedsells| area.
%    \begin{macrocode}
 \@namedef{mcell@#1negjot}{-#3}\@namedef{mcell@#1negtb}{#2}}
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand\negjot[1]{{\jot\mcell@MBnegjot\gape[mcell@MBnegtb]{#1}}}
%    \end{macrocode}
%
% The macros which count advanced height and depth of boxes.
%    \begin{macrocode}
\newcommand\mcell@mb@t[2]{%
  \@tempdima\ht#1\advance\@tempdima#2\ht#1\@tempdima}
\newcommand\mcell@mb@b[2]{%
  \@tempdimb\dp#1\advance\@tempdimb#2\dp#1\@tempdimb}
\newcommand\mcell@mb@tb[2]{\mcell@mb@t{#1}{#2}\mcell@mb@b{#1}{#2}}
%    \end{macrocode}
%
% The body of |\gape| macros.
%    \begin{macrocode}
\@ifdefinable\@gape{}\@ifdefinable\@@gape{}
\def\@gape[#1]{\mcell@setgapes{mb}[#1]{\jot}\@@gape}
\def\@@gape{%
  \ifmmode \expandafter\mathpalette\expandafter\mathg@pe
  \else \expandafter\makeg@pe
  \fi}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\makeg@pe}
% The macros which put box with necessary parameters in text and math mode.
%    \begin{macrocode}
\newcommand\makeg@pe[1]{\setbox\z@
  \hbox{\color@begingroup#1\color@endgroup}\mcell@mb@\z@\mcell@mbjot\box\z@}
\newcommand\mathg@pe[2]{\setbox\z@
  \hbox{$\m@th#1{#2}$}\mcell@mb@\z@\mcell@mbjot\box\z@}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\Gape}
% The macros which put box with necessary parameters in text and math mode.
%    \begin{macrocode}
\@ifdefinable\Gape{}
\DeclareRobustCommand\Gape{\@ifnextchar[\@Gape{\@Gape[\jot]}}
\@ifdefinable\@Gape{}\@ifdefinable\@@Gape{}
\def\@Gape[#1]{\@ifnextchar[{\@@Gape[#1]}{\@@Gape[#1][#1]}}
\def\@@Gape[#1][#2]{\def\depth{\dp\z@}\def\height{\ht\z@}%
  \edef\mcell@mb@##1##2{%
    \@tempdima\ht\z@\advance\@tempdima#1\ht\z@\@tempdima
    \@tempdimb\dp\z@\advance\@tempdimb#2\dp\z@\@tempdimb}%
    \@@gape}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\topstrut}
% \begin{macro}{\botstrut}
% \begin{macro}{\bottopstrut}
% The macros abbreviations for |\strut| which changed by value of |\jot|.
% First enlarges both depth and height.
%    \begin{macrocode}
\newcommand\bottopstrut{\gape{\strut}}
%    \end{macrocode}
% Second enlarges only height.
%    \begin{macrocode}
\newcommand\topstrut{\gape[t]{\strut}}
%    \end{macrocode}
% Third enlarges only depth.
%    \begin{macrocode}
\newcommand\botstrut{\gape[b]{\strut}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \subsection{Modification of command from \package{array} package}
%
% \begin{macro}{\makegapedcells}
% \begin{macro}{\nomakegapedcells}
% At first is saved |\@classz| macro.
%    \begin{macrocode}
\@ifdefinable\mcell@oriclassz{\let\mcell@oriclassz\@classz}
%    \end{macrocode}
% This macros redefine and restore the |\@classz| macro from \package{array}
% package.
%    \begin{macrocode}
\newcommand\makegapedcells{\let\@classz\mcell@classz}
\newcommand\nomakegapedcells{\let\@classz\mcell@oriclassz}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\mcell@agape}
% Following macro creates tabular/array cells with changed vertical spaces.
%    \begin{macrocode}
\newcommand\mcell@agape[1]{\setbox\z@\hbox{#1}\mcell@MB@\z@\mcell@MBjot
   \null\mcell@left\box\z@\mcell@right\null}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\mcell@classz}
% Redefined |\@classz| macro from \package{array} package.
%    \begin{macrocode}
\newcommand\mcell@classz{\@classx
   \@tempcnta \count@
   \prepnext@tok
   \@addtopreamble{%\mcell@mstyle
      \ifcase\@chnum
         \hfil
         \mcell@agape{\d@llarbegin\insert@column\d@llarend}\hfil \or
         \hskip1sp
         \mcell@agape{\d@llarbegin\insert@column\d@llarend}\hfil \or
         \hfil\hskip1sp
         \mcell@agape{\d@llarbegin \insert@column\d@llarend}\or
         $\mcell@agape{\vcenter
         \@startpbox{\@nextchar}\insert@column\@endpbox}$\or
         \mcell@agape{\vtop
         \@startpbox{\@nextchar}\insert@column\@endpbox}\or
         \mcell@agape{\vbox
         \@startpbox{\@nextchar}\insert@column\@endpbox}%
      \fi
      \global\let\mcell@left\relax\global\let\mcell@right\relax
    }\prepnext@tok}
%    \end{macrocode}
% \end{macro}
%
% \subsection{Rows of skipped and numbered cells}
%
% \begin{macro}{\eline}
% The row of empty cells.
%    \begin{macrocode}
\@ifdefinable\eline{}
\DeclareRobustCommand\eline[1]{\@temptokena{}\count@ #1%
  \advance\count@\m@ne
   \loop \@temptokena\expandafter{\the\@temptokena&}%
    \advance\count@\m@ne \ifnum\count@>\z@\repeat
     \the\@temptokena\ignorespaces}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\erows}
% \begin{macro}{\Xrows}
%   Lazy macros for filling few rows.
%    \begin{macrocode}
%\newtoks\@temptokenb\newtoks\@temptokenc
%\newcommand\erows[3][\\ \hline]{\relax\@temptokenb{}\@temptokenc{}\@tempcnta#3\relax
%     \count@#2\advance\count@\m@ne\loop\showthe\@temptokenc
%     \@temptokenc\expandafter{\the\@temptokenc&}%
%     \advance\count@\m@ne \ifnum\count@>\z@\repeat
%   \loop
%   \global\@temptokenb\expandafter{\the\expandafter\@temptokenb\expandafter\the\@temptokenc#1}%
%   \advance\@tempcnta\m@ne \ifnum\@tempcnta>\z@\repeat
%   \the\@temptokenb\showthe\@temptokenb}
\newcommand\erows[3][\\ \hline]{\@temptokena{}\count@ #3%
   \loop \@temptokena\expandafter{\the\@temptokena\eline{#2}#1}%
    \advance\count@\m@ne \ifnum\count@>\z@\repeat
     \the\@temptokena}
\newcommand\Xrows[2]{\@temptokena{}\count@ #2%
   \loop \@temptokena\expandafter{\the\@temptokena#1}%
    \advance\count@\m@ne \ifnum\count@>\z@\repeat
     \the\@temptokena}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\rnline}
% \begin{macro}{\nline}
% The rows of numbered cells. The |\rnline| command replaces |\Alph| and
% |\alph| counter by |\Asbuk| and |\asbuk| consequently.
%    \begin{macrocode}
\newcounter{nlinenum}
\@ifdefinable\rnline{}
\DeclareRobustCommand\rnline{\gdef
    \TeXr@rus{\let\@Alph\@Asbuk\let\@alph\@asbuk}\@nline}
\@ifdefinable\nline{}
\DeclareRobustCommand\nline{\gdef\TeXr@rus{}\@nline}
\newcommand\@nline{\@ifnextchar[%]
    {\@@nline}{\@@nline[1]}}
\@ifdefinable\@@nline{}
\def\@@nline[#1]{\@ifnextchar[%]
    {\@@@nline[#1]}{\@@@nline[#1][1]}}
\@ifdefinable\@@@nline{}
\def\@@@nline[#1][#2]#3{\count@ #3
  \def\TeXr@label{\TeXr@label@{nlinenum}}%
  \expandafter\TeXr@loop\@gobble{}#1\@@@
  \xdef\Num{\the\TeXr@lab}%
  \c@nlinenum#2\relax%
  \expandafter\@temptokena\expandafter{\Num
    \global\advance\c@nlinenum\@ne}%
  \advance\count@\m@ne
  \loop\@temptokena\expandafter{\the\@temptokena&
        \Num \global\advance\c@nlinenum\@ne}%
    \advance\count@\m@ne \ifnum\count@>\z@ \repeat
     \the\@temptokena\ignorespaces}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% [Borrowed code stuff and explanation from \package{enumerate}/\package{paralist}
% packages just with changes of command names.]
%
% Internal token register used to build up the label command from the
% optional argument.
%    \begin{macrocode}
\newtoks\TeXr@lab
%    \end{macrocode}
% This just expands to a `?'. |\ref| will produce this, if no counter
% is printed.
%    \begin{macrocode}
\def\TeXr@qmark{?}
%    \end{macrocode}
% The next four macros build up the command that will print the item
% label. They each gobble one token or group from the optional argument,
% and add corresponding tokens to the register |\@enLab|. They each end
% with a call to |\@enloop|, which starts the processing of the next
% token.
% \begin{macro}{\TeXr@label}
% Add the counter to the label. |#2| will be one of the `special'
% tokens |A a I i 1|, and is thrown away. |#1| will be a command
% like |\Roman|.
%    \begin{macrocode}
\def\TeXr@label@#1#2#3{%
  \edef\TeXr@the{\noexpand#2{#1}}%
  \TeXr@lab\expandafter
    {\the\TeXr@lab\TeXr@rus\csname the#1\endcsname}%
  \advance\@tempcnta1
  \TeXr@loop}
%    \end{macrocode}
% The only foreign command in this stuff. It indicates whether
% the list has numeration by Russian letters.
%    \begin{macrocode}
\def\TeXr@rus{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\TeXr@space}
% \begin{macro}{\TeXr@sp@ce}
% Add a space to the label. The tricky bit is to gobble the space token,
% as you can not do this with a macro argument.
%    \begin{macrocode}
\def\TeXr@space{\afterassignment\TeXr@sp@ce\let\@tempa= }
\def\TeXr@sp@ce{\TeXr@lab\expandafter{\the\TeXr@lab\space}\TeXr@loop}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\TeXr@group}
% Add a |{ }| group to the label.
%    \begin{macrocode}
\def\TeXr@group#1{\TeXr@lab\expandafter{\the\TeXr@lab{#1}}\TeXr@loop}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\TeXr@other}
% Add anything else to the label
%    \begin{macrocode}
\def\TeXr@other#1{\TeXr@lab\expandafter{\the\TeXr@lab#1}\TeXr@loop}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\TeXr@loop}
% \begin{macro}{\TeXr@loop@}
% The body of the main loop.
% Eating tokens this way instead of using |\@tfor| lets you see
% spaces and {\bf all} braces. |\@tfor| would treat {\tt a} and
% |{a}| as  special, but not |{{a}}|.
%    \begin{macrocode}
\def\TeXr@loop{\futurelet\TeXr@temp\TeXr@loop@}
%    \end{macrocode}
%    \begin{macrocode}
\def\TeXr@loop@{%
  \ifx A\TeXr@temp         \def\@tempa{\TeXr@label\Alph  }\else
  \ifx a\TeXr@temp         \def\@tempa{\TeXr@label\alph  }\else
  \ifx i\TeXr@temp         \def\@tempa{\TeXr@label\roman }\else
  \ifx I\TeXr@temp         \def\@tempa{\TeXr@label\Roman }\else
  \ifx 1\TeXr@temp         \def\@tempa{\TeXr@label\arabic}\else
  \ifx \@sptoken\TeXr@temp \let\@tempa\TeXr@space         \else
  \ifx \bgroup\TeXr@temp   \let\@tempa\TeXr@group         \else
  \ifx \@@@\TeXr@temp      \let\@tempa\@gobble          \else
                           \let\@tempa\TeXr@other
%    \end{macrocode}
%    Hook for possible extensions
%    \begin{macrocode}
                         \TeXr@hook
                 \fi\fi\fi\fi\fi\fi\fi\fi
  \@tempa}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\TeXr@hook}
%    \begin{macrocode}
\providecommand\TeXr@hook{}
%    \end{macrocode}
% \end{macro}
%
% \subsection{Diagonally separated column heads}
%
% \begin{macro}{\diaghead}
% Macro for diagonally separated column heads.
%    \begin{macrocode}
\newcommand\diaghead{\@ifnextchar({\mcell@diaghead}{\mcell@diagheads}}
\@ifdefinable\mcell@diaghead{}
\def\mcell@diaghead(#1){\def\celldiagratio{(#1)}\mcell@diagheads}
%    \end{macrocode}
% The default value of diagonal ratio.
%    \begin{macrocode}
\newcommand\celldiagratio{(5,-2)}
%    \end{macrocode}
% The building itself
%    \begin{macrocode}
\newcommand\mcell@diagheads[3]{\hbox\bgroup\expandafter
    \mcell@getcelldiagratios\celldiagratio\relax
    \@tempswafalse
%    \end{macrocode}
% depends of sign of ratios.
%    \begin{macrocode}
    \ifnum\mcell@Hratio<\z@\count@-\mcell@Hratio\relax
        \edef\mcell@Hratio{\the\count@}\relax
        \ifnum\mcell@Vratio<\z@\count@-\mcell@Vratio\relax
            \edef\mcell@Vratio{\the\count@}\else\@tempswatrue
        \fi
    \else
        \ifnum\mcell@Vratio<\z@\count@-\mcell@Vratio\relax
            \edef\mcell@Vratio{\the\count@}\@tempswatrue\else
        \fi
    \fi
    \settowidth\@tempdima{#1}\advance\@tempdima2\tabcolsep
    \edef\mcell@diagH{\the\@tempdima}\divide\@tempdima\mcell@Hratio
    \@tempdima\mcell@Vratio\@tempdima\edef\mcell@diagV{\the\@tempdima}%
%    \end{macrocode}
% The |\unitlength| here is |\relaxed|, we use just real dimensions.
%    \begin{macrocode}
    \let\mcell@oriunitlength\unitlength\let\unitlength\relax
    \kern-\tabcolsep\kern-\@wholewidth
    \setbox\z@\hbox{\theadfont{\strut}}\@tempdima\dp\z@
%    \end{macrocode}
% The value of compensate vertical spacing defined here experimentally
% and equals to 2~default line thickness.
%    \begin{macrocode}
    \advance\@tempdima.8\p@%2\@wholewidth
%    \end{macrocode}
% If |\makedgapedcells| switched on for the table there is
% compensate spacing.
%    \begin{macrocode}
    {\ifx\@classz\mcell@classz
        \setbox\z@\hbox{#1}\ht\z@\z@\dp\z@\z@
        \mcell@MB@\z@\mcell@MBjot
        \global\dimen@\@tempdima\global\@tempdimb\@tempdimb
     \else\global\dimen@\z@\global\@tempdimb\z@\fi
        }%
    \advance\@tempdima\dimen@
    \edef\mcell@diagVoffset{\the\@tempdima}%
    \@tempdima\mcell@diagV\advance\@tempdima-\mcell@diagVoffset
    \advance\@tempdima-\@tempdimb
    \edef\mcell@diagVcorr{\the\@tempdima}%
    \noindent\nomakegapedcells\hbox{\begin{tabular}{@{}c@{}}%
%    \end{macrocode}
% At least a~|\normallineskip| vertical space from top and bottom of cell.
%    \begin{macrocode}
    \ifdim\jot<2\p@\jot2\p@\fi
    \if@tempswa
%    \end{macrocode}
% For South-East or North-West directions.
%    \begin{macrocode}
        \begin{picture}(\mcell@diagH,\mcell@diagVcorr)(\z@,\mcell@diagVoffset)%
        \put(\z@,\mcell@diagV){\makebox(\z@,\z@)[tl]%
            {\edef\tempa{(\mcell@Hratio,-\mcell@Vratio)}\expandafter
             \line\tempa{\mcell@diagH}}}
        \put(\tabcolsep,\jot)%
            {\makebox(\z@,\z@)[bl]{\theadfont
                \let\cellset\theadset\makecell[bl]{\strut#2}}}
        \@tempdima\mcell@diagH\advance\@tempdima-\tabcolsep
        \@tempdimb\mcell@diagV\advance\@tempdimb-\jot
        \put(\@tempdima,\@tempdimb)%
            {\makebox(\z@,\z@)[tr]{\theadfont
                \let\cellset\theadset\makecell[tr]{#3\strut}}}
        \end{picture}%
    \else
%    \end{macrocode}
% For South-West or North-East directions.
%    \begin{macrocode}
        \begin{picture}(\mcell@diagH,\mcell@diagVcorr)(\z@,\mcell@diagVoffset)%
        \put(\z@,\mcell@diagV){\makebox(\z@,\z@)[tl]%
            {\edef\tempa{(\mcell@Hratio,\mcell@Vratio)}\expandafter
             \line\tempa{\mcell@diagH}}}
        \@tempdima\mcell@diagV\advance\@tempdima-\jot
        \put(\tabcolsep,\@tempdima)%
            {\makebox(\z@,\z@)[tl]{\theadfont
                \let\cellset\theadset\makecell[tl]{\strut#3}}}
        \@tempdima\mcell@diagH\advance\@tempdima-\tabcolsep
        \put(\@tempdima,\jot)%
            {\makebox(\z@,\z@)[br]%
            {\theadfont
                \let\cellset\theadset{\makecell[br]{#2\strut}}}}
        \end{picture}%
    \fi
    \end{tabular}%
    \kern-\tabcolsep\kern-\@wholewidth
    }\let\unitlength\mcell@oriunitlength\egroup\par
    \ifvmode\strut
    \vspace*{-\normalbaselineskip}\vspace*{-\normallineskip}
    \fi
}
%    \end{macrocode}
% \end{macro}
% Macro used by previous one. Extracts ratios for defining of height of cell.
%    \begin{macrocode}
\@ifdefinable\mcell@getcelldiagratios{}
\def\mcell@getcelldiagratios(#1,#2){\def\mcell@Hratio{#1}\def\mcell@Vratio{#2}}
%    \end{macrocode}
%
%   \subsection{The \cmd{\hline} and \cmd{\cline} with necessary thickness}
%
% \begin{macro}{\Xhline}
%   The commands for |\hline| and |\cline| with necessary thickness.
%   Added code for the |longtable| environment.
%    \begin{macrocode}
\newcommand\Xhline[1]{\noalign{\ifnum0=`}\fi\arrayrulewidth#1%
        \ifx\hline\LT@hline\let\@xhline\LT@@hline\fi
        \hrule\@height\arrayrulewidth\futurelet\reserved@a\@xhline}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\Xcline}
%    \begin{macrocode}
\def\Xcline#1#2{\@Xcline#1;#2\@nil}
\def\@Xcline#1-#2;#3\@nil{%
  \omit
  \@multicnt#1%
  \advance\@multispan\m@ne
  \ifnum\@multicnt=\@ne\@firstofone{&\omit}\fi
  \@multicnt#2%
  \advance\@multicnt-#1%
  \advance\@multispan\@ne
  \leaders\hrule\@height#3\hfill
  \cr
  \noalign{\vskip-#3}}
%    \end{macrocode}
% \end{macro}
%
% \Finale
\endinput