summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2013-05-28 22:11:43 +0000
committerKarl Berry <karl@freefriends.org>2013-05-28 22:11:43 +0000
commit8defb22e02cd94f41d0ba5ee5bd8e2aaadff5ada (patch)
treebef3dad48e940e88a907bba7299985bd8b0802fa
parent2d189c5a0198efa41ac86ee057fbbe24ff0bc36b (diff)
cals (28may13)
git-svn-id: svn://tug.org/texlive/trunk@30784 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--Master/texmf-dist/doc/latex/cals/cals.pdfbin261090 -> 236426 bytes
-rw-r--r--Master/texmf-dist/doc/latex/cals/examples/demo.pdfbin62193 -> 58125 bytes
-rw-r--r--Master/texmf-dist/doc/latex/cals/examples/demo.tex2
-rw-r--r--Master/texmf-dist/doc/latex/cals/test/README3
-rw-r--r--Master/texmf-dist/doc/latex/cals/test/regression/test_060_alignment.chk106
-rw-r--r--Master/texmf-dist/doc/latex/cals/test/regression/test_060_alignment.tex37
-rw-r--r--Master/texmf-dist/doc/latex/cals/test/regression/test_065_alignment.chk45
-rw-r--r--Master/texmf-dist/doc/latex/cals/test/regression/test_065_alignment.tex25
-rw-r--r--Master/texmf-dist/source/latex/cals/cals.dtx22
-rw-r--r--Master/texmf-dist/source/latex/cals/table.dtx67
-rw-r--r--Master/texmf-dist/tex/latex/cals/cals.sty41
11 files changed, 316 insertions, 32 deletions
diff --git a/Master/texmf-dist/doc/latex/cals/cals.pdf b/Master/texmf-dist/doc/latex/cals/cals.pdf
index 0e9bafd05b3..a87645f1e76 100644
--- a/Master/texmf-dist/doc/latex/cals/cals.pdf
+++ b/Master/texmf-dist/doc/latex/cals/cals.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/cals/examples/demo.pdf b/Master/texmf-dist/doc/latex/cals/examples/demo.pdf
index 2428fd5375d..bb83c39ca9b 100644
--- a/Master/texmf-dist/doc/latex/cals/examples/demo.pdf
+++ b/Master/texmf-dist/doc/latex/cals/examples/demo.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/cals/examples/demo.tex b/Master/texmf-dist/doc/latex/cals/examples/demo.tex
index 2dfe0c03e53..0e165fffa34 100644
--- a/Master/texmf-dist/doc/latex/cals/examples/demo.tex
+++ b/Master/texmf-dist/doc/latex/cals/examples/demo.tex
@@ -36,7 +36,7 @@
by Oleg Parashchenko\par
\textless{}olpa uucode com\textgreater\par
\par
-26 August 2010\par
+24 May 2013\par
\clearpage
\header{Simple table}
diff --git a/Master/texmf-dist/doc/latex/cals/test/README b/Master/texmf-dist/doc/latex/cals/test/README
index 08e9f94dd16..e96d61b3f2e 100644
--- a/Master/texmf-dist/doc/latex/cals/test/README
+++ b/Master/texmf-dist/doc/latex/cals/test/README
@@ -1,6 +1,7 @@
Unit tests for the CALS package. Usage:
-$ export TEXINPUTS=`pwd`/../cals:
+$ export TEXINPUTS=`pwd`/../dev:
+$ mkdir tmp
$ python support/run_tests.py
or, to execute a subset of the tests,
$ python support/run_tests.py cell/test_10
diff --git a/Master/texmf-dist/doc/latex/cals/test/regression/test_060_alignment.chk b/Master/texmf-dist/doc/latex/cals/test/regression/test_060_alignment.chk
new file mode 100644
index 00000000000..9d3bd56fc42
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/cals/test/regression/test_060_alignment.chk
@@ -0,0 +1,106 @@
+> \boxXX=
+\vbox(150.0+0.0)x290.0
+.\vbox(0.0+0.0)x290.0
+..\hbox(50.0+0.0)x290.0 []
+.\hbox(0.0+0.0)x290.0
+..\glue 50.0
+..\glue -0.2
+..\rule(0.2+0.2)x240.4
+..\glue -0.2
+..\glue 0.0
+.\hbox(100.0+0.0)x290.0
+..\glue 50.0
+..\vbox(100.0+0.0)x240.0 []
+..\glue 0.0
+.\glue 0.0
+.\penalty 10000
+.\vbox(0.0+0.0)x290.0
+..\hbox(50.0+0.0)x290.0 []
+.\hbox(0.0+0.0)x290.0
+..\glue 50.0
+..\glue -0.2
+..\rule(0.2+0.2)x240.4
+..\glue -0.2
+..\glue 0.0
+.\hbox(50.0+0.0)x290.0
+..\glue 50.0
+..\hbox(50.0+0.0)x240.0 []
+..\glue 0.0
+.\hbox(0.0+0.0)x290.0
+..\glue 50.0
+..\glue -0.2
+..\rule(0.2+0.2)x240.4
+..\glue -0.2
+..\glue 0.0
+%
+%
+> \boxXX=
+\vbox(150.0+0.0)x400.0
+.\vbox(0.0+0.0)x400.0
+..\hbox(50.0+0.0)x400.0, glue set 80.0fil []
+.\hbox(0.0+0.0)x400.0, glue set 80.0fil
+..\glue 0.0 plus 1.0fil
+..\glue -0.2
+..\rule(0.2+0.2)x240.4
+..\glue -0.2
+..\glue 0.0 plus 1.0fil
+.\hbox(100.0+0.0)x400.0, glue set 80.0fil
+..\glue 0.0 plus 1.0fil
+..\vbox(100.0+0.0)x240.0 []
+..\glue 0.0 plus 1.0fil
+.\glue 0.0
+.\penalty 10000
+.\vbox(0.0+0.0)x400.0
+..\hbox(50.0+0.0)x400.0, glue set 80.0fil []
+.\hbox(0.0+0.0)x400.0, glue set 80.0fil
+..\glue 0.0 plus 1.0fil
+..\glue -0.2
+..\rule(0.2+0.2)x240.4
+..\glue -0.2
+..\glue 0.0 plus 1.0fil
+.\hbox(50.0+0.0)x400.0, glue set 80.0fil
+..\glue 0.0 plus 1.0fil
+..\hbox(50.0+0.0)x240.0 []
+..\glue 0.0 plus 1.0fil
+.\hbox(0.0+0.0)x400.0, glue set 80.0fil
+..\glue 0.0 plus 1.0fil
+..\glue -0.2
+..\rule(0.2+0.2)x240.4
+..\glue -0.2
+..\glue 0.0 plus 1.0fil
+%
+%
+> \boxXX=
+\vbox(150.0+0.0)x400.0
+.\vbox(0.0+0.0)x400.0
+..\hbox(50.0+0.0)x400.0, glue set 160.0fil []
+.\hbox(0.0+0.0)x400.0, glue set 160.0fil
+..\glue 0.0 plus 1.0fil
+..\glue -0.2
+..\rule(0.2+0.2)x240.4
+..\glue -0.2
+..\glue 0.0
+.\hbox(100.0+0.0)x400.0, glue set 160.0fil
+..\glue 0.0 plus 1.0fil
+..\vbox(100.0+0.0)x240.0 []
+..\glue 0.0
+.\glue 0.0
+.\penalty 10000
+.\vbox(0.0+0.0)x400.0
+..\hbox(50.0+0.0)x400.0, glue set 160.0fil []
+.\hbox(0.0+0.0)x400.0, glue set 160.0fil
+..\glue 0.0 plus 1.0fil
+..\glue -0.2
+..\rule(0.2+0.2)x240.4
+..\glue -0.2
+..\glue 0.0
+.\hbox(50.0+0.0)x400.0, glue set 160.0fil
+..\glue 0.0 plus 1.0fil
+..\hbox(50.0+0.0)x240.0 []
+..\glue 0.0
+.\hbox(0.0+0.0)x400.0, glue set 160.0fil
+..\glue 0.0 plus 1.0fil
+..\glue -0.2
+..\rule(0.2+0.2)x240.4
+..\glue -0.2
+..\glue 0.0
diff --git a/Master/texmf-dist/doc/latex/cals/test/regression/test_060_alignment.tex b/Master/texmf-dist/doc/latex/cals/test/regression/test_060_alignment.tex
new file mode 100644
index 00000000000..08d5b24b6df
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/cals/test/regression/test_060_alignment.tex
@@ -0,0 +1,37 @@
+\def\w{\ht\cals@current@row=50pt\relax}
+\def\mktable{%
+\begin{calstable}
+\colwidths{{70pt}{80pt}{90pt}}
+\def\cals@framecs@width{\cals@cs@width}
+\def\cals@framers@width{\cals@rs@width}
+\setlength{\cals@paddingR}{2pt plus1fil}
+\brow \nullcell{ltr} \cell{b} \cell{c} \w \erow
+\brow \nullcell{lrb}\spancontent{a,d} \cell{e} \cell{f} \w \erow
+\brow \cell{g} \cell{h} \cell{i} \w \erow
+\end{calstable}
+}
+
+\showboxdepth=2
+\hsize=400pt
+
+\setbox0=\vbox{%
+\leftskip=50pt\relax
+\mktable}
+\showbox0
+\box0
+
+\begin{center}
+some text\\
+\setbox0=\vbox{%
+\mktable}
+\showbox0
+\box0
+\end{center}
+
+\begin{flushright}
+some text\\
+\setbox0=\vbox{%
+\mktable}
+\showbox0
+\box0
+\end{flushright}
diff --git a/Master/texmf-dist/doc/latex/cals/test/regression/test_065_alignment.chk b/Master/texmf-dist/doc/latex/cals/test/regression/test_065_alignment.chk
new file mode 100644
index 00000000000..082696a904c
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/cals/test/regression/test_065_alignment.chk
@@ -0,0 +1,45 @@
+> \boxXX=
+\hbox(40.0+0.0)x100.0
+.\vbox(40.0+0.0)x100.0
+..\glue 10.0
+..\glue 0.0 plus -1.0
+..\glue(\parskip) 0.0 plus 1.0
+..\glue(\lineskip) 0.0
+..\hbox(20.0+0.0)x100.0, glue set 80.0fil
+...\glue(\leftskip) 10.0
+...\vbox(20.0+0.0)x0.0
+...\penalty 10000
+...\glue(\parfillskip) 0.0 plus 1.0fil
+...\glue(\rightskip) 10.0
+..\glue 0.0 plus 1.0fil
+..\glue 10.0
+> \boxXX=
+\hbox(40.0+0.0)x100.0
+.\vbox(40.0+0.0)x100.0
+..\glue 10.0
+..\glue 0.0 plus -1.0
+..\glue(\parskip) 0.0 plus 1.0
+..\glue(\lineskip) 0.0
+..\hbox(20.0+0.0)x100.0, glue set 80.0fil
+...\glue(\leftskip) 10.0
+...\vbox(20.0+0.0)x0.0
+...\penalty 10000
+...\glue(\parfillskip) 0.0 plus 1.0fil
+...\glue(\rightskip) 10.0
+..\glue 0.0 plus 1.0fil
+..\glue 10.0
+> \boxXX=
+\hbox(40.0+0.0)x100.0
+.\vbox(40.0+0.0)x100.0
+..\glue 10.0
+..\glue 0.0 plus -1.0
+..\glue(\parskip) 0.0 plus 1.0
+..\glue(\lineskip) 0.0
+..\hbox(20.0+0.0)x100.0, glue set 80.0fil
+...\glue(\leftskip) 10.0
+...\vbox(20.0+0.0)x0.0
+...\penalty 10000
+...\glue(\parfillskip) 0.0 plus 1.0fil
+...\glue(\rightskip) 10.0
+..\glue 0.0 plus 1.0fil
+..\glue 10.0
diff --git a/Master/texmf-dist/doc/latex/cals/test/regression/test_065_alignment.tex b/Master/texmf-dist/doc/latex/cals/test/regression/test_065_alignment.tex
new file mode 100644
index 00000000000..41f0523965c
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/cals/test/regression/test_065_alignment.tex
@@ -0,0 +1,25 @@
+% Alignment outside a table should not affect alignment inside tanle
+\def\tbl{%
+\begin{calstable}
+\colwidths{{100pt}}
+\def\cals@paddingT{10pt}
+\def\cals@paddingR{10pt}
+\def\cals@paddingB{10pt}
+\def\cals@paddingL{10pt}
+\brow
+\cell{\noindent\vbox to 20pt{}}
+\ht\cals@current@row=40pt
+\showbox\cals@current@row
+\erow
+\end{calstable}
+}
+
+\tbl
+
+\begin{center}
+\tbl
+\end{center}
+
+\begin{flushright}
+\tbl
+\end{flushright}
diff --git a/Master/texmf-dist/source/latex/cals/cals.dtx b/Master/texmf-dist/source/latex/cals/cals.dtx
index e0ae6dbac16..b3eef90729e 100644
--- a/Master/texmf-dist/source/latex/cals/cals.dtx
+++ b/Master/texmf-dist/source/latex/cals/cals.dtx
@@ -22,7 +22,7 @@
%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<package>\ProvidesPackage{cals}
%<*package>
- [2010/10/07 CALS tables v.2.0]
+ [2013/05/24 CALS tables v.2.2]
%</package>
%
%<*driver>
@@ -58,6 +58,8 @@
% Right brace \} Tilde \~}
%
%
+% \changes{v2.2}{2013/05/27}{Hooks for bidi support.}
+% \changes{v2.1}{2013/05/24}{Alignment of tables works.}
% \changes{v2.0}{2010/10/08}{Complete rewrite with different approach}
% \changes{v1.0}{2010/06/17}{Initial version from skeleton.dtx}
%
@@ -78,7 +80,7 @@
% with repeatable headers and footers, with cells spanned over
% rows and columns. Decorations are supported: padding, background
% color, width of separation rules. The code is compatible with
-% multicols and pdfsync.
+% multicols, pdfsync and bidi.
%
% The work is released to public (\LaTeX{} license)
% by \url{bitplant.de}~GmbH, a company which provides technical
@@ -86,13 +88,14 @@
%
% \section{Usage}
%
-% An users' guide is a separate document, yet to be written.
-% I'll do it for TUGboat 2011:1. At the moment, as a substitute,
-% use the demo document provided with the package. The most
-% important feature: the table (its rows) must start in a vertical
-% mode, the cells content should switch to a horizontal mode.
+% The users' guide is a separate document, published in TUGboat 2011:2:
+% \url{http://tug.org/TUGboat/tb32-2/tb101parashchenko.pdf}
%
-% Please post questions and suggestions to the newsgroup
+% The most important feature: the table (its rows) must start in a
+% vertical mode, the cells content should switch to a horizontal mode.
+%
+% Please post questions and suggestions to TeX-SX
+% (\url{http://tex.stackexchange.com/}), the newsgroup
% |comp.text.tex| and the |texhax| mailing list (see
% \url{http://tug.org/mailman/listinfo/texhax}),
% not directly to me.
@@ -118,7 +121,8 @@
% |\cals@framers@width|, |\cals@bodyrs@width|. Overrides:
% |\cals@borderL| (|...T,R,B|).
%
-% Hooks: |\cals@AtBeginCell|, |\cals@AtEndCell|.
+% Hooks: |\cals@AtBeginTable|, |\cals@AtEndTable|,
+% |\cals@AtBeginCell|, |\cals@AtEndCell|.
%
% Spanning: |\nullcell|, |\spancontent|.
%
diff --git a/Master/texmf-dist/source/latex/cals/table.dtx b/Master/texmf-dist/source/latex/cals/table.dtx
index 0e55a9378f1..e4eb37dfb7b 100644
--- a/Master/texmf-dist/source/latex/cals/table.dtx
+++ b/Master/texmf-dist/source/latex/cals/table.dtx
@@ -101,9 +101,10 @@
\setbox\cals@backup@cs=\box\cals@current@cs
\let\cals@backup@rs@above=\cals@current@rs@above
\let\cals@backup@context=\cals@last@context
- \cals@backup@leftskip=\leftskip
- \cals@backup@rightskip=\rightskip
- \leftskip=0pt \rightskip=0pt \relax
+ \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}%
@@ -122,6 +123,7 @@
\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
}
@@ -237,13 +239,45 @@
% \end{macrocode}
% \end{macro}
+% \begin{macro}{\cals@set@tohsize}
+% \begin{macro}{\cals@tohsize}
+% Table row contains not only the row itself, but also |\leftskip|
+% and |\rightskip|. Now the dilemma. If the row is just |\hbox|,
+% than the glue component is ignored, and the table always aligned
+% left. On the other side, if the row is |\hbox to \hsize|, then
+% the user gets underfulled boxes. A simple solution is to
+% switch on and off the |hsize|-part depending on the skips.
+% \begin{macrocode}
+\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
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+
+% \begin{macro}{\cals@activate@rtl}
+% \begin{macro}{\cals@deactivate@rtl}
+% \begin{macro}{\cals@hbox}
+% For bidi support, use |\hboxR| instead of |\hbox|.
+% \begin{macrocode}
+\newcommand\cals@hbox{}
+\newcommand\cals@activate@rtl{\let\cals@hbox=\hboxR}
+\newcommand\cals@deactivate@rtl{\let\cals@hbox=\hbox}
+\cals@deactivate@rtl
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+
% \begin{macro}{\cals@issue@rowsep@alone}
% Typesets the top (or bottom) frame of a table:
% combines |\cals@current@rs@above| and |\cals@framers@width|
% and outputs the row separator.
% \begin{macrocode}
\newcommand\cals@issue@rowsep@alone{%
-\setbox0=\hbox{%
+\setbox0=\cals@hbox\cals@tohsize{%
\hskip\leftskip
\cals@rs@sofar@reset
\cals@rs@joinOne\cals@framers@width\cals@current@rs@above
@@ -269,7 +303,7 @@
\ifx \cals@last@context\cals@current@context
\let\cals@tmpIII=\cals@rs@width \else
\let\cals@tmpIII=\cals@bodyrs@width \fi
- \setbox0=\hbox{%
+ \setbox0=\cals@hbox\cals@tohsize{%
\hskip\leftskip
\cals@rs@sofar@reset
\cals@rs@joinTwo\cals@tmpIII\cals@last@rs@below\cals@current@rs@above
@@ -298,15 +332,15 @@
% Decorations: first the column separation, then the row separation.
% \begin{macrocode}
\nointerlineskip
-\setbox0=\vtop{\hbox{\hskip\leftskip \box\cals@current@cs \hskip\rightskip}}%
- \ht0=0pt \box0
+\setbox0=\vtop{\cals@hbox\cals@tohsize{\hskip\leftskip \box\cals@current@cs \hskip\rightskip}}%
+\ht0=0pt\relax\box0
\nointerlineskip
\cals@issue@rowsep
\nointerlineskip
% \end{macrocode}
% Output the row, update the last context.
% \begin{macrocode}
-\hbox{\hskip\leftskip \box\cals@current@row \hskip\rightskip}%
+\cals@hbox\cals@tohsize{\hskip\leftskip \box\cals@current@row \hskip\rightskip}%
\let\cals@last@rs@below=\cals@current@rs@below
\let\cals@last@context=\cals@current@context}
% \end{macrocode}
@@ -325,16 +359,29 @@
\let\cals@last@context=n%
\let\cals@current@context=b%
\parindent=0pt %
-\cals@setpadding{Ag}\cals@setcellprevdepth{Al}%
+\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
+\cals@AtBeginTable
}{% End of the table
-\cals@tfoot@tokens\lastrule}
+\cals@tfoot@tokens\lastrule\cals@AtEndTable}
% \end{macrocode}
% \end{environment}
+% \begin{macro}{\cals@AtBeginTable}
+% \begin{macro}{\cals@AtEndTable}
+% Callbacks for more initialization possibilities.
+% \begin{macrocode}
+\newcommand\cals@AtBeginTable{}%
+\newcommand\cals@AtEndTable{}%
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+
% \begin{macro}{\lastrule}
% Typesets the last rule (bottom frame) of a table chunk.
% Repeatable calls are ignored.
diff --git a/Master/texmf-dist/tex/latex/cals/cals.sty b/Master/texmf-dist/tex/latex/cals/cals.sty
index c187fc25d18..b3244e2498b 100644
--- a/Master/texmf-dist/tex/latex/cals/cals.sty
+++ b/Master/texmf-dist/tex/latex/cals/cals.sty
@@ -29,7 +29,7 @@
%%
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{cals}
- [2010/10/07 CALS tables v.2.0]
+ [2013/05/24 CALS tables v.2.2]
\newcommand\cals@cell[3]{}
@@ -273,9 +273,10 @@
\setbox\cals@backup@cs=\box\cals@current@cs
\let\cals@backup@rs@above=\cals@current@rs@above
\let\cals@backup@context=\cals@last@context
- \cals@backup@leftskip=\leftskip
- \cals@backup@rightskip=\rightskip
- \leftskip=0pt \rightskip=0pt \relax
+ \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}%
@@ -289,6 +290,7 @@
\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
}
@@ -331,8 +333,19 @@
\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=\hbox{%
+\setbox0=\cals@hbox\cals@tohsize{%
\hskip\leftskip
\cals@rs@sofar@reset
\cals@rs@joinOne\cals@framers@width\cals@current@rs@above
@@ -345,7 +358,7 @@
\ifx \cals@last@context\cals@current@context
\let\cals@tmpIII=\cals@rs@width \else
\let\cals@tmpIII=\cals@bodyrs@width \fi
- \setbox0=\hbox{%
+ \setbox0=\cals@hbox\cals@tohsize{%
\hskip\leftskip
\cals@rs@sofar@reset
\cals@rs@joinTwo\cals@tmpIII\cals@last@rs@below\cals@current@rs@above
@@ -358,12 +371,12 @@
\newcommand\cals@issue@row{%
\nointerlineskip
-\setbox0=\vtop{\hbox{\hskip\leftskip \box\cals@current@cs \hskip\rightskip}}%
- \ht0=0pt \box0
+\setbox0=\vtop{\cals@hbox\cals@tohsize{\hskip\leftskip \box\cals@current@cs \hskip\rightskip}}%
+\ht0=0pt\relax\box0
\nointerlineskip
\cals@issue@rowsep
\nointerlineskip
-\hbox{\hskip\leftskip \box\cals@current@row \hskip\rightskip}%
+\cals@hbox\cals@tohsize{\hskip\leftskip \box\cals@current@row \hskip\rightskip}%
\let\cals@last@rs@below=\cals@current@rs@below
\let\cals@last@context=\cals@current@context}
@@ -376,13 +389,19 @@
\let\cals@last@context=n%
\let\cals@current@context=b%
\parindent=0pt %
-\cals@setpadding{Ag}\cals@setcellprevdepth{Al}%
+\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
+\cals@AtBeginTable
}{% End of the table
-\cals@tfoot@tokens\lastrule}
+\cals@tfoot@tokens\lastrule\cals@AtEndTable}
+
+\newcommand\cals@AtBeginTable{}%
+\newcommand\cals@AtEndTable{}%
\newcommand\lastrule{%
\ifx r\cals@last@context \relax \else