From 4a55147e264bbcb051fbb9a51b05b190e52bd6b7 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Fri, 25 Nov 2016 22:39:44 +0000 Subject: cals (25nov16) git-svn-id: svn://tug.org/texlive/trunk@42577 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/source/latex/cals/cals.dtx | 31 +++++--- Master/texmf-dist/source/latex/cals/cals.ins | 1 + Master/texmf-dist/source/latex/cals/cell.dtx | 25 +++++-- Master/texmf-dist/source/latex/cals/rtl.dtx | 42 +++++++++++ Master/texmf-dist/source/latex/cals/table.dtx | 103 +++++++++++++++++++------- 5 files changed, 157 insertions(+), 45 deletions(-) create mode 100644 Master/texmf-dist/source/latex/cals/rtl.dtx (limited to 'Master/texmf-dist/source/latex') diff --git a/Master/texmf-dist/source/latex/cals/cals.dtx b/Master/texmf-dist/source/latex/cals/cals.dtx index b3eef90729e..0f746973249 100644 --- a/Master/texmf-dist/source/latex/cals/cals.dtx +++ b/Master/texmf-dist/source/latex/cals/cals.dtx @@ -1,6 +1,6 @@ % \iffalse meta-comment % -% Copyright (C) 2010 by Oleg Parashchenko +% Copyright (C) 2010-2017 by Oleg Parashchenko % ------------------------------------------------------- % % This file may be distributed and/or modified under the @@ -22,7 +22,7 @@ %\NeedsTeXFormat{LaTeX2e}[1999/12/01] %\ProvidesPackage{cals} %<*package> - [2013/05/24 CALS tables v.2.2] + [2016/11/23 CALS tables v.2.4.1] % % %<*driver> @@ -58,6 +58,8 @@ % Right brace \} Tilde \~} % % +% \changes{v2.4.1}{2016/11/23}{Bug fixes for row separation lines.} +% \changes{v2.4}{2014/11/12}{Built-in RTL (right-to-left) support.} % \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} @@ -80,7 +82,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, pdfsync and bidi. +% multicols and bidi. % % The work is released to public (\LaTeX{} license) % by \url{bitplant.de}~GmbH, a company which provides technical @@ -89,20 +91,22 @@ % \section{Usage} % % The users' guide is a separate document, published in TUGboat 2011:2: -% \url{http://tug.org/TUGboat/tb32-2/tb101parashchenko.pdf} +% \url{http://tug.org/TUGboat/tb32-2/tb101parashchenko.pdf}. There are +% examples on CTAN: \url{https://www.ctan.org/pkg/cals}. % % The most important feature: the table (its rows) must start in a % vertical mode, the cells content should switch to a horizontal mode. +% For using the commands with the |@| symbol you might need to say +% |\makeatletter| first. % -% 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. +% Please post questions and suggestions to the |texhax| mailing list +% (\url{http://tug.org/mailman/listinfo/texhax}) or on \TeX-\LaTeX{} +% Stack Exchange site (\url{http://tex.stackexchange.com/}) with the +% tag |cals|. % % Summary of the user interface: % \begin{verbatim} -% \begin{calstable} +% \begin{calstable} % [n|l|c|r] % \colwidths{{100pt}{200pt}} % \brow \cell{a} \cell{b} \erow % \end{calstable} @@ -110,7 +114,10 @@ % % Table elements: |\thead|, |\tfoot|, |\tbreak{\penalty-10000}|, |\lastrule|. % -% Alignment: |\alignL|, |\alignC|, |\alignR|, |\vfill|. +% Table alignment: |l|, |c|, |r| for left, center and right; +% |n| for none, using the default |\leftskip| and |\rightskip|. +% +% In-cell alignment: |\alignL|, |\alignC|, |\alignR|, |\vfill|. % % Padding: lengths |\cals@paddingL| (|...T,R,B|), set by |\cals@setpadding{Ag}|, % baseline alignment |\cals@paddingD|, set by |\cals@setcellprevdepth{Al}|. @@ -158,6 +165,7 @@ % elements. The second part starts with the common code, % then explains in-row decorations (column separation and cells % background) and between-row decorations (row separation). + % % \input{cell.dtx} % \input{span.dtx} @@ -166,6 +174,7 @@ % \input{decor.dtx} % \input{colsep.dtx} % \input{rowsep.dtx} +% \input{rtl.dtx} % % \Finale diff --git a/Master/texmf-dist/source/latex/cals/cals.ins b/Master/texmf-dist/source/latex/cals/cals.ins index 6c85c8f34e4..1fea8a3210d 100644 --- a/Master/texmf-dist/source/latex/cals/cals.ins +++ b/Master/texmf-dist/source/latex/cals/cals.ins @@ -42,6 +42,7 @@ and version 1.2 or later is part of all distributions of LaTeX version \from{decor.dtx}{package} \from{colsep.dtx}{package} \from{rowsep.dtx}{package} + \from{rtl.dtx}{package} }} \obeyspaces diff --git a/Master/texmf-dist/source/latex/cals/cell.dtx b/Master/texmf-dist/source/latex/cals/cell.dtx index 1d72f279557..71ddd4177e4 100644 --- a/Master/texmf-dist/source/latex/cals/cell.dtx +++ b/Master/texmf-dist/source/latex/cals/cell.dtx @@ -219,21 +219,34 @@ % by assigning skip to dimen. % \begin{macrocode} \newcommand\alignL{% -\dimen0=\cals@paddingL \cals@paddingL=\dimen0 \relax -\dimen0=\cals@paddingR \cals@paddingR=\dimen0 \relax} +\cals@vfillDrop\cals@paddingL +\cals@vfillDrop\cals@paddingR} \newcommand\alignC{% -\dimen0=\cals@paddingL \cals@paddingL=\dimen0 plus 1fill\relax -\dimen0=\cals@paddingR \cals@paddingR=\dimen0 plus 1fill\relax} +\cals@vfillAdd\cals@paddingL +\cals@vfillAdd\cals@paddingR} \newcommand\alignR{% -\dimen0=\cals@paddingL \cals@paddingL=\dimen0 plus 1fill\relax -\dimen0=\cals@paddingR \cals@paddingR=\dimen0 \relax} +\cals@vfillAdd\cals@paddingL +\cals@vfillDrop\cals@paddingR} % \end{macrocode} % \end{macro} % \end{macro} % \end{macro} +% \begin{macro}{\cals@vfillAdd} +% \begin{macro}{\cals@vfillDrop} +% Add or remove the |vfill|-part of a skip. Retain the existing +% value if possible. +% \begin{macrocode} +\newcommand\cals@vfillAdd[1]{\ifnum\gluestretchorder#1>1\relax\else +\dimen0=#1\relax #1=\dimen0 plus 1fill\relax \fi} +\newcommand\cals@vfillDrop[1]{\ifnum\gluestretchorder#1>0\relax +\dimen0=#1\relax #1=\dimen0\relax \fi} +% \end{macrocode} +% \end{macro} +% \end{macro} + % \subsection{From cells to a row} % \begin{macro}{\cals@current@row} diff --git a/Master/texmf-dist/source/latex/cals/rtl.dtx b/Master/texmf-dist/source/latex/cals/rtl.dtx new file mode 100644 index 00000000000..ed891fd4243 --- /dev/null +++ b/Master/texmf-dist/source/latex/cals/rtl.dtx @@ -0,0 +1,42 @@ +% \subsection{RTL (right-to-left) hooks} + +% \begin{macro}{\if@RTL} +% \begin{macro}{\if@RTLtab} +% \begin{macro}{\@RTLtabtrue} +% Provide RTL status commands even if the RTL packages are not loaded. +% \begin{macrocode} +\def\next{% + \let\if@RTL=\iffalse + \let\if@RTLtab=\iffalse + \let\@RTLtabtrue=\relax +} +\ifdefined\if@RTL \relax \else \next \fi +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} + +% \begin{macro}{\cals@setup@alignment} +% Swap alignment in the RTL mode. +% \begin{macrocode} +\newcommand\cals@setup@alignment[1]{% +\if c#1\relax \cals@vfillAdd \leftskip \cals@vfillAdd \rightskip \fi +\if@RTL + \if l#1\relax \cals@vfillAdd \leftskip \cals@vfillDrop\rightskip \fi + \if r#1\relax \cals@vfillDrop\leftskip \cals@vfillDrop\rightskip \fi +\else + \if l#1\relax \cals@vfillDrop\leftskip \cals@vfillDrop\rightskip \fi + \if r#1\relax \cals@vfillAdd \leftskip \cals@vfillDrop\rightskip \fi +\fi +} +% \end{macrocode} +% \end{macro} + +% \begin{macro}{\cals@hskip@lr} +% Do |hskip| with the first argument, unless in the RTL mode. +% \begin{macrocode} +\newcommand\cals@hskip@lr[2]{% +\if@RTL \hskip#2\relax \else \hskip#1\relax \fi} +% \end{macrocode} +% \end{macro} + diff --git a/Master/texmf-dist/source/latex/cals/table.dtx b/Master/texmf-dist/source/latex/cals/table.dtx index e4eb37dfb7b..94670200024 100644 --- a/Master/texmf-dist/source/latex/cals/table.dtx +++ b/Master/texmf-dist/source/latex/cals/table.dtx @@ -59,8 +59,12 @@ \let\cals@current@context=\cals@backup@context \fi\fi\fi % \end{macrocode} -% Typeset the row. +% Typeset the row. If the width of the row is more than hsize, then +% the issue-code should not fit the row to hsize. % \begin{macrocode} +\ifdim\wd\cals@current@row>\hsize\relax +\def\cals@tohsize{}% +\fi \cals@issue@row % \end{macrocode} % Consider a table such that thead+row1 do not fit to a page @@ -76,8 +80,15 @@ % the first row of a table chunk. % \begin{macrocode} \ifx b\cals@last@context - \ifx h\cals@last@context@bak \vskip0pt \penalty10000 \fi - \ifx n\cals@last@context@bak \vskip0pt \penalty10000 \fi + {\dimen0=\pagetotal\relax + \advance\dimen0 by \cals@tfoot@height\relax + \advance\dimen0 by -\pagegoal + \ifdim\dimen0>0pt\relax + \vskip\dimen0 + \penalty9999 % with 10000, the output page builder is not called + \vskip-\dimen0\relax + \fi + }% \fi } % \end{macrocode} @@ -100,6 +111,7 @@ \setbox\cals@backup@row=\vbox{\box\cals@current@row}% \setbox\cals@backup@cs=\box\cals@current@cs \let\cals@backup@rs@above=\cals@current@rs@above + \let\cals@backup@last@rs@below=\cals@last@rs@below \let\cals@backup@context=\cals@last@context \cals@backup@leftskip=\leftskip\relax \cals@backup@rightskip=\rightskip\relax @@ -120,6 +132,7 @@ \setbox\cals@current@row=\box\cals@backup@row \setbox\cals@current@cs=\box\cals@backup@cs \let\cals@current@rs@above=\cals@backup@rs@above + \let\cals@last@rs@below=\cals@backup@last@rs@below \let\cals@last@context=\cals@backup@context \leftskip=\cals@backup@leftskip \rightskip=\cals@backup@rightskip @@ -190,6 +203,7 @@ % If the user sets |\cals@tbreak@tokens| (using |\tbreak|), % break is forced. Otherwise, no break is allowed: % \begin{itemize} +% \item inside a box (= inside a float) % \item In the header % \item In the footer % \item Immediately after the header @@ -206,22 +220,23 @@ \let\cals@tmp=\cals@iffalse \let\cals@tmpII=\cals@iftrue \ifx\relax\cals@tbreak@tokens - \ifx h\cals@current@context \else - \ifx f\cals@current@context \else - \ifx h\cals@last@context \else - \ifx n\cals@last@context \else - \dimen0=\pagetotal\relax - \advance\dimen0 by \ht\cals@current@row\relax - %\showthe\ht\cals@current@row\relax - \ifx \cals@tfoot@tokens\relax \else - %\show\cals@tfoot@height\relax - \advance\dimen0 by \cals@tfoot@height\relax - \fi - %\showthe\dimen0\relax - \ifdim \dimen0>\pagegoal\relax - \let\cals@tmp=\cals@tmpII - \fi - \fi\fi\fi\fi + \ifinner\else + \ifx h\cals@current@context \else + \ifx f\cals@current@context \else + \ifx h\cals@last@context \else + \ifx n\cals@last@context \else + \dimen0=\pagetotal\relax + \advance\dimen0 by \ht\cals@current@row\relax + %\showthe\ht\cals@current@row\relax + \ifx \cals@tfoot@tokens\relax \else + %\show\cals@tfoot@height\relax + \advance\dimen0 by \cals@tfoot@height\relax + \fi + %\showthe\dimen0\relax + \ifdim \dimen0>\pagegoal\relax + \let\cals@tmp=\cals@tmpII + \fi + \fi\fi\fi\fi\fi \else \let\cals@tmp=\cals@tmpII % tbreak@tokens \fi \cals@tmp} @@ -261,6 +276,9 @@ % \begin{macro}{\cals@deactivate@rtl} % \begin{macro}{\cals@hbox} % For bidi support, use |\hboxR| instead of |\hbox|. +% Actually, more is required for bidi support, and +% these macros are retained only as "legacy". +% Otherwise I'd move the code into the beginning of `calstable`. % \begin{macrocode} \newcommand\cals@hbox{} \newcommand\cals@activate@rtl{\let\cals@hbox=\hboxR} @@ -278,11 +296,11 @@ % \begin{macrocode} \newcommand\cals@issue@rowsep@alone{% \setbox0=\cals@hbox\cals@tohsize{% - \hskip\leftskip + \cals@hskip@lr\leftskip\rightskip \cals@rs@sofar@reset \cals@rs@joinOne\cals@framers@width\cals@current@rs@above \cals@rs@sofar@end - \hskip\rightskip}% + \cals@hskip@lr\rightskip\leftskip}% \ht0=0pt \dp0=0pt \box0 } % \end{macrocode} % \end{macro} @@ -304,11 +322,11 @@ \let\cals@tmpIII=\cals@rs@width \else \let\cals@tmpIII=\cals@bodyrs@width \fi \setbox0=\cals@hbox\cals@tohsize{% - \hskip\leftskip + \cals@hskip@lr\leftskip\rightskip \cals@rs@sofar@reset \cals@rs@joinTwo\cals@tmpIII\cals@last@rs@below\cals@current@rs@above \cals@rs@sofar@end - \hskip\rightskip}% + \cals@hskip@lr\rightskip\leftskip}% \ht0=0pt \dp0=0pt \box0 % \fi} % \end{macrocode} @@ -332,7 +350,8 @@ % Decorations: first the column separation, then the row separation. % \begin{macrocode} \nointerlineskip -\setbox0=\vtop{\cals@hbox\cals@tohsize{\hskip\leftskip \box\cals@current@cs \hskip\rightskip}}% +\setbox0=\vtop{\cals@hbox\cals@tohsize{\cals@hskip@lr\leftskip\rightskip +\box\cals@current@cs \cals@hskip@lr\rightskip\leftskip}}% \ht0=0pt\relax\box0 \nointerlineskip \cals@issue@rowsep @@ -340,9 +359,11 @@ % \end{macrocode} % Output the row, update the last context. % \begin{macrocode} -\cals@hbox\cals@tohsize{\hskip\leftskip \box\cals@current@row \hskip\rightskip}% +\cals@hbox\cals@tohsize{\cals@hskip@lr\leftskip\rightskip +\box\cals@current@row \cals@hskip@lr\rightskip\leftskip}% \let\cals@last@rs@below=\cals@current@rs@below -\let\cals@last@context=\cals@current@context} +\let\cals@last@context=\cals@current@context +\nobreak} % \end{macrocode} % \end{macro} @@ -351,14 +372,16 @@ % \begin{environment}{\calstable} % Setup the parameters and let the row dispatcher to do all the work. % \begin{macrocode} -\newenvironment{calstable}{% +\newenvironment{calstable}[1][\cals@table@alignment]{% +\if@RTL\@RTLtabtrue\cals@activate@rtl\fi \let\cals@thead@tokens=\relax \let\cals@tfoot@tokens=\relax \let\cals@tbreak@tokens=\relax \cals@tfoot@height=0pt \relax \let\cals@last@context=n% \let\cals@current@context=b% -\parindent=0pt % +\parindent=0pt \relax% +\cals@setup@alignment{#1}% \cals@setpadding{Ag}\cals@setcellprevdepth{Al}\cals@set@tohsize% %% Alignment inside is independent on center/flushright outside \parfillskip=0pt plus1fil\relax @@ -366,6 +389,14 @@ \let\cals@borderR=\relax \let\cals@borderT=\relax \let\cals@borderB=\relax +% \end{macrocode} +% Bug fix for \url{http://tex.stackexchange.com/questions/167400/fancyhdr-and-cals-vertical-merge-problem}. +% Table inside a table is ok, but when there are 1) page break inside +% a table in the text flow, and 2) a table with a vertically straddled +% cell is created in the output procedure, then this table inside table +% needs additional cleaning. +% \begin{macrocode} +\setbox\cals@backup@row=\box\voidb@x\relax \cals@AtBeginTable }{% End of the table \cals@tfoot@tokens\lastrule\cals@AtEndTable} @@ -432,3 +463,19 @@ \newcommand\tbreak[1]{\def\cals@tbreak@tokens{#1}} % \end{macrocode} % \end{macro} + +% \begin{macro}{\cals@table@alignment} +% The default alignment of tables in the text flow. +% Doesn't affect the text alignment inside cells. +% \begin{itemize} +% \item |n|: no settings, the default |\leftskip| and |\rightskip| are used +% \item |l|: align left +% \item |c|: align center +% \item |r|: align right +% \end{itemize} +% This setting is appeared in the version 2.3. Earlier versions +% worked as it were |n|. +% \begin{macrocode} +\newcommand\cals@table@alignment{l} +% \end{macrocode} +% \end{macro} -- cgit v1.2.3