summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/tabls
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/latex/contrib/tabls
Initial commit
Diffstat (limited to 'macros/latex/contrib/tabls')
-rw-r--r--macros/latex/contrib/tabls/miscdoc.sty95
-rw-r--r--macros/latex/contrib/tabls/tabls.pdfbin0 -> 231978 bytes
-rw-r--r--macros/latex/contrib/tabls/tabls.sty238
-rw-r--r--macros/latex/contrib/tabls/tabls.tex83
4 files changed, 416 insertions, 0 deletions
diff --git a/macros/latex/contrib/tabls/miscdoc.sty b/macros/latex/contrib/tabls/miscdoc.sty
new file mode 100644
index 0000000000..bd16122bab
--- /dev/null
+++ b/macros/latex/contrib/tabls/miscdoc.sty
@@ -0,0 +1,95 @@
+\ProvidesPackage{miscdoc}[2010/01/20 v1.2 documentation macros misc latex pkgs]
+
+% miscdoc.sty
+% Copyright 2010 Robin Fairbairns
+%
+% This work may be distributed and/or modified under the
+% conditions of the LaTeX Project Public License, either version 1.3
+% of this license or (at your option) any later version.
+% The latest version of this license is in
+% http://www.latex-project.org/lppl.txt
+% and version 1.3 or later is part of all distributions of LaTeX
+% version 2005/12/01 or later.
+%
+% This work has the LPPL maintenance status `maintained'.
+%
+% The Current Maintainer of this work is Robin Fairbairns.
+%
+% This work consists of the file miscdoc.sty (only)
+
+\setcounter{errorcontextlines}{1274}
+
+% The package arose from a small exercise to document packages whose
+% previous documentation consisted solely of comments in the package files.
+% The macros here defined are lifted from the author's faq.sty
+% (written for the UK TeX FAQ, CTAN:help/uk-tex-faq) or are inspired
+% by others' work (credited where the author is known) ... except
+% where they came as a flash of inspiration while actually writing the
+% documentation.
+
+% this option suggested by Heiko Oberdiek, 2010-01-29
+\DeclareOption{hyper}{%
+ \AtEndOfPackage{%
+ \RequirePackage[pdfusetitle]{hyperref}
+ \RequirePackage{bookmark}
+ \bookmarksetup{numbered,open,openlevel=1}
+ }
+}
+\ProcessOptions\relax
+
+% note: T1 encoding assumed
+\usepackage{lmodern}
+\usepackage[T1]{fontenc}
+\usepackage{booktabs}
+
+% from faq.sty
+\newcommand\cs[1]{\texttt{\char`\\#1}}
+\let\csx\cs
+\def\bsbs{\cs{\char`\\}}
+
+% \cmdinvoke\cs<argument sequence>
+% \cs typeset as above
+% <argument sequence> may consist of optional or mandatory arguments;
+%
+% the `arguments' are simply typesett \texttt, as yet -- if something
+% fancier is needed, there's a bunch of code needs rewriting here...
+\DeclareRobustCommand\cmdinvoke{\@ifstar
+ {\let\@tempa\emph\@scmdinvoke}%
+ {\let\@tempa\relax\@scmdinvoke}%
+}
+\def\@scmdinvoke#1{\texttt{\symbol{92}#1}%
+ \futurelet\@let@token\@cmdinvoke
+}
+\def\@cmdinvoke{\ifx\@let@token\bgroup
+ \let\@tempb\@cmdinvoke@lbrace
+ \else
+ \ifx\@let@token[% ]
+ \let\@tempb\@cmdinvoke@lbrack
+ \else
+ \ifx\@let@token(% )
+ \let\@tempb\@cmdinvoke@lparen
+ \else
+ \let\@tempb\@empty
+ \fi
+ \fi
+ \fi
+ \@tempb
+}
+\def\@cmdinvoke@lbrace#1{\penalty0\hskip0pt\relax
+ \texttt{\symbol{123}\@tempa{#1}\symbol{125}}%
+ \futurelet\@let@token\@cmdinvoke
+}
+\def\@cmdinvoke@lbrack[#1]{\penalty-150\hskip0pt\relax
+ \texttt{[\@tempa{#1}]}%
+ \futurelet\@let@token\@cmdinvoke
+}
+\def\@cmdinvoke@lparen(#1){\penalty-150\hskip0pt\relax
+ \texttt{(\@tempa{#1})}%
+ \futurelet\@let@token\@cmdinvoke
+}
+
+% sui generis
+\newcommand\newitem{\par\addvspace{1ex}\noindent}
+
+% inspired by doc.sty in latex distribution
+\newcommand\meta[1]{\ensuremath{\langle}\emph{#1}\ensuremath{\rangle}}
diff --git a/macros/latex/contrib/tabls/tabls.pdf b/macros/latex/contrib/tabls/tabls.pdf
new file mode 100644
index 0000000000..b7b8234502
--- /dev/null
+++ b/macros/latex/contrib/tabls/tabls.pdf
Binary files differ
diff --git a/macros/latex/contrib/tabls/tabls.sty b/macros/latex/contrib/tabls/tabls.sty
new file mode 100644
index 0000000000..9ad268ff37
--- /dev/null
+++ b/macros/latex/contrib/tabls/tabls.sty
@@ -0,0 +1,238 @@
+%
+% T A B L S . S T Y (ver 3.5)
+%
+% Copyright (c) 1989-1996 by Donald Arseneau
+%
+% These macros may be freely used, transmitted, reproduced, or modified
+% provided that this notice is left intact.
+%
+% Modify LaTeX's array and tabular environments to keep text from touching
+% other text or hlines above or below. See instructions after \endinput.
+%
+%----------------------------------------------------------------------
+
+% create registers and default settings:
+
+\newdimen\tablinesep \tablinesep= 1pt \let\tablineskip=\tablinesep
+\newdimen\arraylinesep \arraylinesep= 1pt \let\arraylineskip=\arraylinesep
+\newdimen\extrarulesep \extrarulesep= 3pt
+
+\newdimen\@arstdepth \newdimen\@arstheight \newdimen\@skip@bove
+
+\let\@tarlinesep\z@ % so outermost arrays will not act nested
+
+% Change the initializations to create a smaller strut and include
+% my macros in the initialization for the preamble.
+
+\def\@array[#1]#2{% remember global variables to allow recursion:
+ \edef\@unrecurse{\global\@skip@bove\the\@skip@bove
+ \global\@arstheight\the\@arstheight\global\@arstdepth\the\@arstdepth}%
+% Make the strut on the first line be shorter by the linesep outside
+ \let\@otarlinesep\@tarlinesep \global\@skip@bove-\@otarlinesep
+% This setup works for both tabular and array because of this test:
+ \ifx\@classz\@arrayclassz \let\@tarlinesep\arraylinesep
+ \else \let\@tarlinesep\tablinesep \fi
+ \divide\@tarlinesep\tw@ % half sep is applied to height & depth
+ \let\@seesize\relax \let\@rememsize\relax \@mkpream{#2}%
+ \@tempdima\arraystretch\ht\strutbox \@tempdimb\arraystretch\dp\strutbox
+ \ifdim\@tarlinesep>\z@ % (need \protect for \multicolumn)
+ \def\@rememsize{\protect\@r@m@msize}\let\@seesize\@s@@size
+ \advance\@tempdima-\@tarlinesep \advance\@tempdimb-\@tarlinesep
+ \fi \setbox\@arstrutbox\hbox{% set up smaller strut
+ \vrule \@height\@tempdima \@depth\@tempdimb \@width\z@}%
+ \let\protect\noexpand
+ \edef\@preamble{\ialign \noexpand\@halignto \bgroup
+ \unhcopy\@arstrutbox \@preamble \tabskip\z@skip &\@sharp \cr}%
+% I have added an extra column (&\@sharp) to take the smart strut.
+ \let\@startpbox\@@startpbox \let\@endpbox\@@endpbox
+ \if#1t\vtop \else \if#1b\vbox \else \vcenter \fi\fi
+ \bgroup \let\par\@empty
+ \global\@arstheight\ht\@arstrutbox \global\@arstdepth\dp\@arstrutbox
+ \advance\extrarulesep.5\arrayrulewidth
+ \let\@sharp##\let\protect\relax \lineskip\z@skip \baselineskip\z@skip
+ \@preamble}
+
+% Change the meaning of \\ to do the final strut calculation and
+% put in the smart strut
+
+\def\@xtabularcr{\@ifnextchar[{\@argtabularcr}{\@argtabularcr[\z@]}}
+
+\def\@xarraycr{\aftergroup\@argarraycr\@xtabularcr}
+
+\def\@argarraycr{${}}% put this "aftergroup" so we can combine macro streams
+
+% Sense a following \end, and adjust spacing accordingly;
+% Sense a rule below, as signalled by "\noalign" after expansion
+
+\def\@argtabularcr[#1]{\ifnum\z@=`{\fi}&\omit % end group, new column
+ {\ifnum\z@=`}\fi
+ \global\advance\@arstheight\@skip@bove % use \@skip@bove so it is available
+ \global\@skip@bove#1\relax % actually, the skip below
+ \@ifnextchar\end{\global\advance\@arstdepth-\@otarlinesep\@mystrutcr}%
+ {\expandafter\expandafter\expandafter\@xargarraycr}}
+
+\def\@xargarraycr{\@ifnextchar\noalign
+ {\global\advance\@arstdepth\extrarulesep \@mystrutcr}%
+ {\@mystrutcr}}
+
+\def\@mystrutcr{% \@skip@bove is really the parameter for skip below here
+ \ifdim\@skip@bove>\z@ \advance\@arstdepth\@skip@bove \global\@skip@bove\z@\fi
+ \advance\@arstheight\@tarlinesep \advance\@arstdepth\@tarlinesep
+ \vrule \@height\@arstheight \@depth\@arstdepth \@width\z@
+ \global\@arstheight\ht\@arstrutbox \global\@arstdepth\dp\@arstrutbox
+ \ifnum\z@=`{\fi}\cr
+ \ifdim\@skip@bove<\z@ \noalign{\vskip\@skip@bove \global\@skip@bove\z@}\fi}
+
+% Simulate \crcr at the end of the table, assuming that we are not in
+% vmode once a line of entries has started. This fails to put in a smart
+% strut if the table ends without \\ while in vmode in a column entry.
+% Use \@unrecurse to simulate grouping of global parameters.
+% For nested tables and arrays, the final strut is reduced by the linesep
+% that will be added at the outer level.
+
+\def\endtabular{\endarray $\egroup}
+
+\expandafter\let\csname endtabular*\endcsname=\endtabular
+
+\def\endarray{\ifvmode\csname crcr\endcsname % just do \crcr if \\ given
+ \else \\[\z@ \global\advance\@arstdepth-\@otarlinesep]%
+ \fi\egroup\@unrecurse\egroup}
+
+% Put \@seesize...\@rememsize in all preamble templates
+
+\def\@tabclassz{\ifcase \@lastchclass \@acolampacol \or \@ampacol \or
+ \or \or \@addamp \or
+ \@acolampacol \or \@firstampfalse \@acol \fi
+\edef\@preamble{\@preamble{%
+ \ifcase
+ \@chnum \hfil\@seesize\ignorespaces\@sharp\unskip\@rememsize \hfil
+ \or \@seesize\ignorespaces\@sharp\unskip\@rememsize \hfil
+ \or \hfil\hskip\z@skip\@seesize\ignorespaces\@sharp\unskip\@rememsize
+ \fi}}}
+
+\def\@arrayclassz{\ifcase \@lastchclass \@acolampacol \or \@ampacol \or
+ \or \or \@addamp \or
+ \@acolampacol \or \@firstampfalse \@acol \fi
+\edef\@preamble{\@preamble
+ \ifcase \@chnum
+ \hfil\@seesize $\relax\@sharp$\@rememsize \hfil
+ \or \@seesize $\relax\@sharp$\@rememsize \hfil
+ \or \hfil\@seesize $\relax\@sharp$\@rememsize \fi}}
+
+\def\@classv{\@addtopreamble{\@seesize\@startpbox{\@nextchar}%
+ \ignorespaces\@sharp\@endpbox\@rememsize}}
+
+% my macros to keep track of the size of entries.
+
+\def\@s@@size{\setbox\z@\hbox\bgroup\bgroup}
+
+\def\@r@m@msize{\egroup\egroup % end the \hbox
+ \ifdim\ht\z@>\@arstheight \global\@arstheight\ht\z@ \fi
+ \ifdim\dp\z@>\@arstdepth \global\@arstdepth \dp\z@ \fi
+ \unhbox\z@}
+
+% Redefine \hline to remove notches and to give extrarulesep and
+% optional [] skip
+
+\def\hline{\noalign{\ifnum\z@=`}\fi\kern-.5\arrayrulewidth
+ \hrule \@height \arrayrulewidth \kern-.5\arrayrulewidth
+ \global\@skip@bove\extrarulesep
+ \@ifnextchar[\@yhline{\expandafter\expandafter\expandafter\@zhline}}
+
+\def\@xhline{\ifx\@tempa\noalign \vskip\doublerulesep \fi % may be the opt.
+ \ifnum`{=\z@\fi}}
+
+\def\@yhline[#1]{\doublerulesep#1\global\advance\@skip@bove#1\relax
+ \expandafter\expandafter\expandafter\@zhline}
+
+\def\@zhline{\futurelet\@tempa\@xhline}%
+
+% make \cline give the \extrarulesep below
+
+\let\TB@cline\cline
+
+\def\cline#1{\noalign{\kern-.5\arrayrulewidth}%
+ \TB@cline{#1}%
+ \noalign{\global\@skip@bove\extrarulesep \kern.5\arrayrulewidth}}%
+
+\endinput
+% -----------------------------------------------------------------
+%
+% Modify LaTeX's array and tabular environments to keep text from touching
+% other text or hlines above or below. There are three new parameters:
+%
+% \tablinesep (or \tablelineskip): minimum space between text on successive
+% lines in a tabular environment. Negative distances are
+% treated as zero. The default value is 1pt. 0pt turns off
+% checking for touching text. Text given in an @{ }
+% specification is never checked for overlap.
+%
+% \arraylinesep (or \arraylineskip): like \tablinesep, but for arrays.
+%
+% \extrarulesep : extra space to add above and below each \hline and \cline.
+% There will be at least \extrarulesep + 0.5\tablinesep
+% between an \hline and a line of text. Negative values can
+% be used, but only until some text touches the line.
+% The default value is 3pt.
+%
+% To ensure interline separations in tables but not arrays, declare
+% \setlength\arraylinesep{0pt}
+% The appearance of normal LaTeX tables can be had with
+% \setlength\tablinesep{0pt}
+% \setlength\arraylinesep{0pt}
+% \setlength\extrarulesep{0pt}
+% but it would be better to not use tabls in this situation.
+%
+% \hline[dimen]:
+%
+% \hline has been changed to take an optional length argument just like \\
+% giving the space to insert below. This space is in addition to the
+% \extrarulesep and linesep. A negative value will reduce the space until
+% the hline touches some text below, and then will have no further effect.
+% E.g., \hline[-9in] draws a horizontal line while suppressing the extrarulesep
+% beneath. Also, the new \hline FIXES THE NOTCHES that used to appear at the
+% junction between horizontal and vertical lines.
+%
+% How it works:
+% There are no struts in the preamble entries (lie), rather, there are
+% tests to measure the maximum height and depth of all entries on a line.
+% The maximum values start at the size of LaTeX's \@arstrut minus the
+% appropriate linesep. At the \\, a strut is inserted (in its own
+% column) which is that maximum size plus the linesep plus any additional
+% space for separation from \hline s.
+%
+% The Downside:
+% Building a table will be slower than before because the entries have to
+% be boxed twice (by \@seesize and by \halign itself) instead of just once.
+% \setlength\tablinesep{0pt} will recover most of this speed, with
+% \extrarulesep still partially in effect--extra space will still be added
+% around hlines, but it may be taken up by very tall or very deep table
+% entries; thus text may still touch the lines. Because of the speed penalty,
+% if your computer is slow, it is probably best to omit the TABLS option
+% until producing a final copy.
+%
+% (2.2) \endtabular* is defined (it was left out before. oops!)
+% change some \z@ to \z@skip. Thanks to Michael Downes.
+% Create alias \tablinesep = \tablelineskip for consistency with
+% \tabcolsep nomenclature. \def\\{\crcr} used in ver 2.1 didn't work right,
+% so use \csname crcr\endcsname.
+%
+% (3.0) Arrays are included! The very top and bottom struts of nested
+% arrays are reduced by the lesser of the inner and outer lineseps so space
+% doesn't accumulate with each level of nesting.
+%
+% (3.1 & 3.2 & 3.3) Minor changes to match LaTeX updates.
+%
+% (3.4) More extensive changes, prompted by LaTeX updates. You can now hide
+% \hline in another macro, and it is still recognized. [Similar commands that
+% add \extrarulesep must begin with \noalign.] \hline[3pt]\hline is now
+% reasonable. (Also try \hline[0pt]\hline!)
+%
+% (3.5) Fix several (non-crashing) bugs introduced in 3.4
+%
+% Send problem reports to asnd@triumf.ca
+%
+% Test integrity of file:
+% brackets: round, square, curly, angle: () [] {} <>
+% backslash, slash, vertical, at, dollar, and: \ / | @ $ &
+% hat, grave, acute (apostrophe), quote, tilde: ^ ` ' " ~
diff --git a/macros/latex/contrib/tabls/tabls.tex b/macros/latex/contrib/tabls/tabls.tex
new file mode 100644
index 0000000000..cf5f82e5ca
--- /dev/null
+++ b/macros/latex/contrib/tabls/tabls.tex
@@ -0,0 +1,83 @@
+\documentclass[a4paper]{article}
+\usepackage[a4paper]{geometry}
+\usepackage{miscdoc}
+\usepackage[scaled=0.85]{luximono}
+\begin{document}
+\title{The \textsf{tabls} package}
+\author{Donald Arseneau\thanks{Documentation derived from the package
+ file by Robin Fairbairns}}
+\maketitle
+\begin{quote}
+ The package modifies \LaTeX{}'s \texttt{array} and \texttt{tabular}
+ environments to keep text from touching other text or hlines above
+ or below.
+\end{quote}
+\section{New parameters, etc.}
+
+The behaviour of the package is controlled by a small set of
+parameters, which are all \TeX{} \cs{dimen} registers (and so may be
+adjusted using \LaTeX{} \cs{setlength} commands.
+
+\paragraph{\cs{tablinesep} (or \cs{tablelineskip}):} the minimum space
+between text on successive lines in a tabular environment. Negative
+distances are treated as zero. The default value is \texttt{1pt}. A
+value of \texttt{0pt} turns off checking for touching text. Text
+given in an \verb|@{ }| specification (cf. the \textsf{array} package)
+is never checked for overlap.
+
+\paragraph{\cs{arraylinesep} (or \cs{arraylineskip})}: like
+\cs{tablinesep}, but for arrays.
+
+\paragraph{\cs{extrarulesep}:} extra space to add above and below each
+\cs{hline} and \cs{cline}. There will be at least
+\texttt{\cs{extrarulesep} + 0.5\cs{tablinesep}} between an \cs{hline}
+and a line of text. Negative values can be used, but only until some
+text touches the line. The default value is \texttt{3pt}.
+
+\noindent To ensure interline separations in tables but not arrays,
+declare
+\begin{quote}
+ \cs{setlength}\cmdinvoke{arraylinesep}{0pt}
+\end{quote}
+\noindent The appearance of normal \LaTeX{} tables can be had with
+\begin{quote}
+ \cs{setlength}\cmdinvoke{tablinesep}{0pt}\\
+ \cs{setlength}\cmdinvoke{arraylinesep}{0pt}\\
+ \cs{setlength}\cmdinvoke{extrarulesep}{0pt}
+\end{quote}
+\noindent but it would be better to not use \textsf{tabls} in this
+situation.
+
+The command \cmdinvoke{hline}[extra] has gained an optional length
+argument (just like \bsbs), which gives the space to insert below the
+line. This space is in addition to the \cs{extrarulesep} and
+linesep. A negative value will reduce the space until the line
+touches some text below, and will then have no further effect. For
+example, \cmdinvoke{hline}[-9cm] draws a horizontal line while
+suppressing all the extra spacing.
+
+(This \cs{hline} also fixes the notches that used to appear at the
+junction between horizontal and vertical lines.)
+
+\section{How it works}
+
+There are no struts in the preamble entries\footnote{The comments in
+ the package say this is a lie\dots}, rather, there are tests to
+measure the maximum height and depth of all entries on a line. The
+maximum values start at the size of LaTeX's \cs{@arstrut} minus the
+appropriate linesep. At the \bsbs, a strut is inserted (in its own
+column) which is that maximum size plus the linesep plus any
+additional space for separation from \cs{hline}s.
+
+\section{The Downside}
+
+Building a table will be slower than before because the entries have
+to be boxed twice (by the package's \cs{@seesize} and by \cs{halign}
+itself) instead of just once.
+\cs{setlength}\cmdinvoke{tablinesep}{0pt} will recover most of this
+speed, with \cs{extrarulesep} still partially in effect\,---\,extra
+space will still be added around \cs{hline}s, but it may be taken up
+by very tall or very deep table entries; thus text may still touch the
+lines. Because of the speed penalty, if your computer is slow, it is
+probably best to omit \textsf{tabls} until producing a final copy.
+\end{document}