[texhax] A macro programming question
Vafa Khalighi
vafaklg at gmail.com
Mon Sep 12 08:05:14 CEST 2011
I am trying to figure out how I can make longtable typeset RTL tabulars but
I started with something much simpler to understand what I should do. The
bigtabular package is defined as:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newskip\Tabularleftskip \Tabularleftskip\@flushglue
\newskip\Tabularrightskip \Tabularrightskip\@flushglue
\newbox\Tabularbox
\newcount\Tabularcount
\newcount\Tabularcolumns
\def\@Tabclassz{\global\advance\Tabularcount\@ne\@tabclassz}
\let\@latexclassiii\@classiii
\def\@Tabclassiii{\global\advance\Tabularcount\@ne\@latexclassiii}
\def\@Tabularcr{{\ifnum0=`}\fi\@ifstar{\@xTabularcr}{\@xTabularcr}}
\def\@xTabularcr{\@ifnextchar[{\@argTabularcr}{\ifnum0=`{\fi}\cr
\noalign{\pagebreak[1]}}}
\def\@argTabularcr[#1]{\ifnum0=`{\fi}\ifdim #1>\z@
\unskip\@xargarraycr{#1}\else \@yargarraycr{#1}\fi
\noalign{\pagebreak[1]}}
\let\@latexhline\hline
\let\@latextabarray\@tabarray
\def\@tabarray{\let\hline\@latexhline\@latextabarray}
\def\Tabularhline{\multispan{\Tabularcolumns}{\unskip\leaders\hrule
height\arrayrulewidth\hfill}\cr
\noalign{\vskip-\arrayrulewidth\pagebreak[2]}%
\multispan{\Tabularcolumns}{\unskip\leaders\hrule
height\arrayrulewidth\hfill}\cr}
\def\Tabular#1{\trivlist\item[]\noindent
\setbox\Tabularbox\vbox\bgroup
\let\@acol\@tabacol
\let\@classz\@Tabclassz
\let\@classiii\@Tabclassiii
\let\@classiv\@tabclassiv
\let\\\@Tabularcr
\setbox\@arstrutbox=\hbox{\vrule
height\arraystretch \ht\strutbox
depth\arraystretch \dp\strutbox
width\z@}%
\global\Tabularcount\z@
\@mkpream{#1}%
\Tabularcolumns\Tabularcount
\let\hline\Tabularhline
\let\@classiii\@latexclassiii
\tabskip\Tabularleftskip
\edef\@preamble{\halign to\linewidth\bgroup
\tabskip\z@ \@arstrut \@preamble
\tabskip\Tabularrightskip \cr}%
\let\@starpbox\@@startpbox
\let\@endpbox\@@endpbox
\let\@sharp##\let\protect\relax
\lineskip\z@\baselineskip\z@
\@preamble}
\def\endTabular{\crcr\egroup\egroup\unvbox\Tabularbox\endtrivlist}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
To make it typeset tabular right to left, I thought of changing \Tabular and
\endTabular as follow:
\def\Tabular#1{\trivlist\item[]\noindent
\setbox\Tabularbox\vbox\bgroup
\let\@acol\@tabacol
\let\@classz\@Tabclassz
\let\@classiii\@Tabclassiii
\let\@classiv\@tabclassiv
\let\\\@Tabularcr
\setbox\@arstrutbox=\hbox{\vrule
height\arraystretch \ht\strutbox
depth\arraystretch \dp\strutbox
width\z@}%
\global\Tabularcount\z@
\@mkpream{#1}%
\Tabularcolumns\Tabularcount
\let\hline\Tabularhline
\let\@classiii\@latexclassiii
\tabskip\Tabularleftskip
\edef\@preamble{\halign to\linewidth\bgroup
\tabskip\z@ \@arstrut \@preamble
\tabskip\Tabularrightskip \cr}%
\let\@starpbox\@@startpbox
\let\@endpbox\@@endpbox
\let\@sharp##\let\protect\relax
\lineskip\z@\baselineskip\z@
\hbox\bgroup\beginR\vbox\bgroup \@preamble}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% This is my first change
\def\endTabular{\crcr\egroup\egroup\endR\egroup\egroup\unvbox\Tabularbox\endtrivlist}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
but it no longer works (tabular appears on one page and no pagebreak
happens). What should I do to fix this?
Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://tug.org/pipermail/texhax/attachments/20110912/e9335d4c/attachment.html>
More information about the texhax
mailing list