diff options
author | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
commit | e0c6872cf40896c7be36b11dcc744620f10adf1d (patch) | |
tree | 60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/latex/contrib/ctable |
Initial commit
Diffstat (limited to 'macros/latex/contrib/ctable')
35 files changed, 1721 insertions, 0 deletions
diff --git a/macros/latex/contrib/ctable/README b/macros/latex/contrib/ctable/README new file mode 100644 index 0000000000..b39ffc2289 --- /dev/null +++ b/macros/latex/contrib/ctable/README @@ -0,0 +1,27 @@ +| +-------:|:-------------------------------------- + ctable:| Flexible typesetting of table and figure floats using key/value directives +Version:| 1.31 + Author:| Wybo Dekker + E-mail:| wybo@dekkerdocumenten.nl +License:| Released under the LaTeX Project Public License v1.3c or later + See:| http://www.latex-project.org/lppl.txt + +Short description: +ctable.sty provides commands to easily typeset centered or left or right +aligned tables and (multiple-)figure floats, with footnotes. Instead of an +environment, a command with 4 arguments is used; the first is optional and +is used for key,value pairs generating variations on the defaults and +offering a route for future extensions. + +Full documentation: +https://bitbucket.org/wybodekker/ctable/downloads/ctable.pdf + +Installation: +Execute the inst script with the --help option for more information. + +Changes in version 1.31: + - comments about tmark in captions + - use expandonce from etoolbox + - use \AtBeginDocument, not \AtEndPreamble from etoolbox + (problems with tikz) diff --git a/macros/latex/contrib/ctable/ctable.dtx b/macros/latex/contrib/ctable/ctable.dtx new file mode 100644 index 0000000000..0469db5410 --- /dev/null +++ b/macros/latex/contrib/ctable/ctable.dtx @@ -0,0 +1,1290 @@ +% \iffalse meta-comment +%<*internal> +\iffalse +%</internal> +%<*readme> +| +-------:|:-------------------------------------- + ctable:| Flexible typesetting of table and figure floats using key/value directives + Author:| Wybo Dekker + E-mail:| wybo@dekkerdocumenten.nl +License:| Released under the LaTeX Project Public License v1.3c or later + See:| http://www.latex-project.org/lppl.txt + +Short description: +ctable.sty provides commands to easily typeset centered or left or right +aligned tables and (multiple-)figure floats, with footnotes. Instead of an +environment, a command with 4 arguments is used; the first is optional and +is used for key,value pairs generating variations on the defaults and +offering a route for future extensions. + +Full documentation: +https://bitbucket.org/wybodekker/ctable/downloads/ctable.pdf + +Installation: +Execute the inst script with the --help option for more information. + +%</readme> +%<*internal> +\fi +%</internal> +%<*driver> +\ProvidesFile{ctable.dtx} +%</driver> +%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01] +%<package>\ProvidesPackage{ctable} +%<*package> + [2015/10/17 v1.31 ctable package for flexible typesetting of table and + figure floats using key/value directives] +%</package> +% +%<*driver> +\documentclass{ltxdoc} +\usepackage{ctable,txfonts,paralist,desclist} +\usepackage[l2tabu,orthodox]{nag} +\usepackage[a4paper,margin=20mm,left=50mm,nohead]{geometry} +\usepackage[colorlinks]{hyperref} +\usepackage{tocloft} +\setlength\cftparskip{.5ex} +\setlength\cftbeforesecskip{.5ex} +\setlength\cftaftertoctitleskip{1ex} +\graphicspath{{./doc/}} +\definecolor{vbgreen}{rgb}{0,.6,0} +\definecolor{B}{rgb}{0.77, 0.90, 0.96} +\definecolor{Y}{rgb}{1,1,.878} +\def\REF#1{\href{http://www.ctan.org/pkg/#1}{\texttt{#1}}} +\parindent0pt\parskip1ex +\newcommand{\ROW}[3]{\parskip0pt% + \colorbox{#1}{% + \parbox{.98\hsize}{% + \rule{0pt}{1.5ex}\\% + \parbox{.6\hsize}{\includegraphics{#2}}% + \parbox{.4\hsize}{\centering{\includegraphics{#3}}}% + \\\rule{0pt}{1.5ex}% + }% + }\par% +} +\AtBeginDocument{\RecordChanges} +\AtEndDocument{\PrintChanges} +\CodelineIndex\EnableCrossrefs +\hypersetup{ + pdftitle = The ctable package, + pdfauthor = Wybo Dekker, + pdfsubject = {Typesetting centered, right, and left aligned table and figure + floats, with many configuration options}, + pdfkeywords = { + table floats, + figure floats, + key=value options, + footnotes, + booktabs, + tabularx, + threeparttable + }, + bookmarksopen +} +\begin{document} + \DocInput{ctable.dtx} + \PrintChanges + \PrintIndex +\end{document} +%</driver> +% \fi +% +% \CheckSum{0} +% +% \CharacterTable +% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z +% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z +% Digits \0\1\2\3\4\5\6\7\8\9 +% Exclamation \! Double quote \" Hash (number) \# +% Dollar \$ Percent \% Ampersand \& +% Acute accent \' Left paren \( Right paren \) +% Asterisk \* Plus \+ Comma \, +% Minus \- Point \. Solidus \/ +% Colon \: Semicolon \; Less than \< +% Equals \= Greater than \> Question mark \? +% Commercial at \@ Left bracket \[ Backslash \\ +% Right bracket \] Circumflex \^ Underscore \_ +% Grave accent \` Left brace \{ Vertical bar \| +% Right brace \} Tilde \~} +% +% +% \changes{v1.00}{2000/06/01}{ +% first release. +% } +% \changes{v1.01}{2001/03/17}{ +% making use of booktabs package +% } +% \changes{v1.02}{2002/06/24}{ +% using keyval to reduce args to 4 +% } +% \changes{v1.03}{2002/07/16}{ +% many syntactic corrections, thanks to Johannes Braams +% } +% \changes{v1.04}{2003/08/11}{ +% - caption, if empty, will not be typeset\\ +% - rotate option added\\ +% - star option added to use table* and figure*\\ +% - environments +% } +% \changes{v1.06}{2004/03/20}{ +% - left, right and center options added\\ +% - frame{sep,rule,fg,bg} options added\\ +% - error in width-setting corrected +% } +% \changes{v1.05}{2003/10/03}{ +% maxwidth option added +% } +% \changes{v1.06a}{2004/04/01}{ +% - made setting fboxsep and fboxrule only temporary\\ +% - removed superfluous space after tabulars +% } +% \changes{v1.06b}{2004/06/19}{ +% added several % at eol to remove superfluous whitespace occurring +% sometimes +% } +% \changes{v1.07}{2005/08/09}{ +% - added option sideways, option rotate now obsolete\\ +% - added option captionskip +% } +% \changes{v1.08}{2006/04/10}{ +% - standardized file setup following +% http://www.ctan.org/tex-archive/info/dtxtut/dtxtut.pdf\\ +% - mincapwidth option added\\ +% - moved newdimen definition outside ctable macro +% } +% \changes{v1.09}{2007/03/04}{ +% - added option nosuper\\ +% - corrected incorrect positioning when table is wider than mincapwidth +% } +% \changes{v1.10}{2007/08/17}{ +% - footnote markers now stay superscript with nosuper\\ +% - documentation: added many examples for the options\\ +% - corrected some unwanted white space in captions\\ +% - caption package included to correct booktabs errors in caption +% position. And for later use of its facilities\\ +% - *captionskip option redefined*: 0pt value now corresponds to LaTeX +% default +% } +% \changes{v1.11}{2007/09/07}{ +% - added some percent signs at EOL to prevent whitespace\\ +% - removed xspace usage - caused overfull badness +% } +% \changes{v1.12}{2008/04/12}{ +% option notespar added +% } +% \changes{v1.13}{2008/05/01}{ +% - cap option with empty argument will not be inserted in lot/lof\\ +% - added option continued, for continuation tables: same number as +% previous table, `(continued)' added to caption +% } +% \changes{v1.14}{2009/09/15}{ +% - nosuper propagation to later tables prohibited\\ +% - added option doinside\\ +% - use of (obsolete) carom.sty for docs discontinued\\ +% - empty labels not created\\ +% - newcolumntype warnings removed\\ +% - caption package not needed anymore +% } +% \changes{v1.15}{2009/09/17}{ +% - removed whitespace before tables\\ +% - corrected marginpars in the documentation +% } +% \changes{v1.16}{2010/06/26}{ +% - option cap={} did not suppress lot/lof entry\\ +% - notespar option now generates fully justified notes +% } +% \changes{v1.17}{2010/10/30}{ +% - doinside option propagated in subsequent ctable calls +% } +% \changes{v1.18}{2011/04/15}{ +% - added setupctable for option defaults\\ +% - added complement for several options (topcap, nosideways, et cetera) +% } +% \changes{v1.19}{2011/05/01}{ +% - sideways option did not work anymore; corrected +% } +% \changes{v1.20}{2011/08/24}{ +% - added options captionsleft, captionsright, captionsinside; (for +% setupctable only) +% } +% \changes{v1.21}{2011/09/05}{ +% - better documentation for sideways, captionsleft/right/inside options +% } +% \changes{v1.22}{2012/05/25}{ +% - allow empty lines in last (tabular) argument\\ +% - corrected error from hyperref's nameref calls (thanks Marco Daniel!) +% } +% \changes{v1.23}{2012/05/28}{ +% - footerwidth option added +% } +% \changes{v1.24}{2013/04/28}{ +% - require xcolor instead of color\\ +% - added option bgopacity\\ +% - added option sidecap (for memoir only) +% } +% \changes{v1.25}{2013/05/24}{ +% - url's to CTAN corrected +% } +% \changes{v1.26}{2013/06/15}{ +% - footerwidth option was inactive when notespar option was active +% } +% \changes{v1.27}{2013/12/19}{ +% - label option did not work with side caption\\ +% - disable transparency with warning if tikz package loaded +% } +% \changes{v1.28}{2014/02/20}{ +% - added percent characters at EOLs causing whitespace +% } +% \changes{v1.29}{2014/04/20}{ +% - reorganized inst script +% } +% \changes{v1.30}{2015/08/29}{ +% - tikz' transparency got broken when tikz loaded after ctable\\ +% - removed overfull hboxes from documentation +% } +% \changes{v1.31}{2015/10/03}{ +% - comments about tmark in captions\\ +% - use expandonce from etoolbox\\ +% - use \AtBeginDocument, not \AtEndPreamble from etoolbox +% (problems with tikz) +% } +% +% \GetFileInfo{ctable.dtx} +% +% \DoNotIndex{ \newcommand, \\, \,, +% \def, \definecolor, \hbox, \raggedright, +% \else, \ifdim, \sbox, \empty, +% \ifx, \setkeys, \end, \label, +% \specialrule, \fboxrule, \let, \tabularnewline, +% \PackageError, \fboxsep, \newbox, \textit, +% \PackageWarningNoLine, \fcolorbox, \newcolumntype, \usebox, +% \RequirePackage, \fi, \newdimen, \vspace, +% \begin, \footnotesize, \normalfont, \wd, +% \define@key, +% } +% +% \title{The \textsf{ctable} package\thanks{This document +% corresponds to \textsf{ctable}~\fileversion, dated \filedate.}} +% \author{Wybo Dekker \\ \texttt{wybo@dekkerdocumenten.nl}} +% +% \maketitle +% \begin{abstract}\noindent +% The \texttt{ctable} package provides a \texttt{ctable} +% command for the typesetting of table and figure floats. You will +% not need to type the usual nested begin...end sequences, as +% \texttt{ctable} is a command, not an environment. \texttt{ctable} +% has only 4 arguments, but the optional first one may hold many +% \textsl{key=value} pairs and makes \texttt{ctable} very flexible +% and extensible. It uses Simon Fear's \REF{booktabs} package for +% better vertical spacing around horizontal rules and it provides +% facilities for making table footnotes. +% \end{abstract} +% \tableofcontents +% \section{Introduction} +% +% \section{Purpose} The |ctable| package lets you easily typeset +% captioned table and figure floats with optional +% footnotes. Both caption and footnotes will normally be forced within the +% width of the table. +% If the width of the table is specified, then \REF{tabularx} will be used +% to typeset it, and one or more |X| column specifiers should be specified. +% Otherwise tabular will be used. +% +% This package defines the commands |\ctable|, |\tnote| and +% |\tmark|, and four |\tabularnewline| generating +% commands. The latter generate reasonable amounts of whitespace +% around horizontal rules and are also useful for tabulars +% outside this package. +% +% Since the |ctable| package imports the \REF{array} and \REF{booktabs} +% packages, all commands from those packages are available as well. +% +% Note that, in line with the comments that Simon Fear made +% describing his \REF{booktabs} package, vertical rules for column +% separation can be produced with |\ctable|, but no provisions are +% made to have them make contact with horizontal rules. +% +% \section{Usage} +% \DescribeMacro{\setupctable} +% |\ctable| defaults can be set, either in the preamble or in the body, +% with:\\ +% +% |\setupctable{options} % key=value,...|\\ +% +% \DescribeMacro{\ctable} +% |\ctable| is called with 4 parameters, of which the first is optional: \\ +% +% |\ctable[options] % key=value,...|\\ +% | {coldefs} % for \begin{tabular}|\\ +% | {foottable} % zero or more \tnote commands (see below)|\\ +% | {table rows} % rows for the table|\\ +% +% Options are given as key=value pairs, separated by comma's. +% Extra comma's, including one behind the last pair, don't hurt. +% Arguments to option should be put between braces if they contain +% comma's or equals signs. +% \section{Options} +% Currently the following option keys have been defined: +% +% { \marginparwidth25mm +% \DescribeMacro{bgopacity=...\hfill} +% Sets the opacity of the table's background color, where 1 is 100\% opaque +% (the default), and 0 is completely transparent. One application is with +% watermarking: most watermarking packages print their watermark on the +% background. |ctable|'s background color, which is opaque by default, may +% make the watermark (partially) invisible. You can avoid this by setting +% the |bgopacity| option to a value lower than 1. Note that this works only +% in PDF mode, a warning is issued otherwise.\\ +% Note: there are two limitations to transparency setting: +% \begin{compactenum} +% \item it works only in PDF mode: so it works in pdflatex and lualatex, +% but is disabled in xelatex. +% \item it disables transparency features in the tikz package; therefore, +% ctable checks if the tikz package is loaded and if so, disables its own +% transparency with a warning. That helps only if you load tikz +% \textit{before} ctable. +% \end{compactenum} +% +% \DescribeMacro{botcap\hfill} +% put the caption at the bottom of the float instead of on top of it. +% See also: |topcap|, |sidecap|. +% +% \DescribeMacro{caption=...\hfill} +% table caption; the braces are needed only if your caption contains a +% comma or an equals sign. +% +% \DescribeMacro{cap=...\hfill} +% for a short caption to go to the |\listoftables|. Without the |cap| +% option, the full caption will go into the |\listoftables|. If |cap| is +% given an empty value, \textsl{and you have loaded the |caption| package}, +% no entry in the |\listoftables| will be made. This may be useful, for +% example, with the |continued| option. +% +% \DescribeMacro{captionskip=...\hfill} +% moves the caption relative to the table; the default is |0ex|, which puts +% captions at their default \LaTeX\ positions. For the standard \LaTeX\ +% classes this means that a top caption's baseline at +% |1ex| above the top rule position of the table and a bottom caption's +% baseline at |4ex| below the bottom rule position. These dimensions may be +% different for other classes or when other packages are included. The +% |memoir| class and the |caption| package, for example, both typeset +% captions differently, and the combination of both even differs from each +% alone.\footnote{I did some measurements on the whitespace between the +% caption and the top of the table with and without using the caption +% package and/or the memoir class: standard LaTeX: 1ex; memoir: +% 2.32ex; caption: 2.69ex; both memoir and caption: 2.68ex. For the +% distances between bottom caption baselines and the table bottom I found, +% respectively: 3.90ex, 3.41ex, 3.72ex and 3.74ex } Keep in mind that when +% you use the |caption| package in the |memoir| class, |memoir|'s caption +% commands are suspended and |caption|'s commands must be used. +% +% \DescribeMacro{captionsleft\hfill} This option is defined for +% |\setupctable| only, and it is effective only where the |sideways| option +% is used. After |\setupctable{captionsleft}| all tables typeset with the +% |sideways| option will have their captions at the left. +% +% \DescribeMacro{captionsright\hfill} This option is defined for +% |\setupctable| only, and it is effective only where the |sideways| option +% is used. After |\setupctable{captionsright}| all tables typeset with the +% |sideways| option will have their captions at the right. +% +% \DescribeMacro{captionsinside\hfill} +% This option is defined for |\setupctable| only, it is the default, and it is effective +% only where the |sideways| option is used. After +% |\setupctable{captionsinside}| all tables typeset with the |sideways| +% option will have their captions at the left in one-sided documents. In +% twosided documents, captions will be on the left for odd-numbered pages +% and on the right for even-numbered pages. This is the default. +% +% \DescribeMacro{center\hfill} +% center the table in the available text width; this is the default. +% See also: |left|, |right|. +% +% \DescribeMacro{continued=...\hfill} +% if used, the table will be numbered the same as the previous table. If +% used without an argument, the caption will be suffixed with ` +% (continued)', if used with an argument, the suffix will be the argument. +% +% \DescribeMacro{doinside=...\hfill} +% command to be run inside, just before the tabular or tabularx +% environment. You can use this, for example, for the adjustment of the +% font size with |\small|. +% +% \DescribeMacro{figure\hfill} +% produce a figure float instead of a table float. See also: |table|. +% +% \DescribeMacro{footerwidth=...\hfill} +% Footnotes are typeset within the width of the table. When you use the +% |mincapwidth| option, presumably because the table is very narrow, footnotes +% are given the same width as the caption. With small footnotes this may not +% be what you want; this option can be used to give the footnotes their own width. +% Without an argument, they will be typeset within the width of of the table. +% +% \DescribeMacro{framebg={\slshape r g b}\hfill} +% set the background color of the frame (the color inside the frame) to the +% given triplet of \textsl{rgb}-values. The values should be numbers +% between 0 and 1. The default is |1 1 1| (white). +% +% +% \DescribeMacro{framefg={\slshape r g b}\hfill} +% set the foreground color of the frame (the rule color) to the given +% triplet of \textsl{rgb}-values. The values should be numbers between 0 +% and 1. The default is |0 0 0| (black). +% +% +% \DescribeMacro{framerule=...\hfill} +% draw a frame around the table with the given rule thickness. The default +% is |0pt|, so that no frame will be seen. +% +% +% \DescribeMacro{framesep=...\hfill} +% set the distance between the frame and the table to the given dimension. +% The default is |0pt|. +% +% +% \DescribeMacro{label=...\hfill} +% labels the float with |\label|. +% +% \DescribeMacro{left\hfill} +% left align the table in the available text width. See also: |center|, |right|. +% +% \DescribeMacro{maxwidth=...\hfill} +% like the \textsl{width} option, but any |X| column specifiers will be +% replaced with |l| if the resulting table width would thus stay within the +% specified maximum width. This is especially useful where the \LaTeX\ +% source is generated by a script. +% +% \DescribeMacro{mincapwidth=...\hfill} +% sets the minimum width of the float. Without this option, the width is +% set to that of the tabular, and the caption and footnotes are typeset +% within that width. This may be a problem with very narrow tables; +% |mincapwidth| can then be used to give the float a minimum width. The +% tabular will be centered in it. If you don't want the footnotes to be affected +% see the |footerwidth| option. +% +% \DescribeMacro{nonotespar\hfill} +% typeset footnotes in a table; this is the default. See also: |notespar|. +% +% \DescribeMacro{nosideways\hfill} +% undo the sideways option. See also: |sideways|. +% +% \DescribeMacro{nostar\hfill} +% use the un-starred versions of the |table| and |figure| environments; +% this is the default +% +% \DescribeMacro{nosuper\hfill} +% in the footnote table, typeset footnote markers on the line, instead of +% superscripted. +% +% \DescribeMacro{notespar\hfill} +% typeset footnotes in a paragraph instead of in a table. +% +% \DescribeMacro{pos=...\hfill} +% float position, default: |tbp|. +% +% \DescribeMacro{right\hfill} +% right align the table in the available text width. +% +% \DescribeMacro{sidecap\hfill} +% put the caption at the side of the float. Currently, this works only if +% you have loaded the |memoir| class, otherwise an error message is +% generated. The parameters for the caption, such as its vertical +% positioning, width and more, must be set with the appropriate |memoir| +% commands. See also: |botcap|, |topcap|. +% +% \DescribeMacro{sideways\hfill} +% rotate table or figure by 90 degrees anticlockwise and put it on a +% separate page. With the twoside option for the standard \LaTeX\ document +% classes, rotation will be -90 on even pages, unless the options +% |captionleft| or |captionsright| are used. If you use this option, the +% |pos| option is not allowed. See also: |nosideways|, |captionsinside|. +% +% \DescribeMacro{star\hfill} +% use the starred versions of the |table| and |figure| environments, which +% place the float over two columns when the |twocolumn| option or the +% |\twocolumn| command is active. See also: |nostar|. +% +% \DescribeMacro{super\hfill} +% in the footnote table, typeset footnote markers as superscripts; this is +% the default. See also: |nosuper|. +% +% \DescribeMacro{table\hfill} +% produce a table float (this is the default). See also: |figure|. +% +% \DescribeMacro{topcap\hfill} +% put the caption top of the float; this is the default. See also: |botcap|, |sidecap|. +% +% \DescribeMacro{width=...\hfill} +% \REF{tabularx} will be used to typeset the table at the specified +% width\,---\,one or more |X| column specifiers must be provided. +% +% } +% +% \section{The width and maxwidth options} +% When \LaTeX-sources containing tables are generated automatically by a +% script, it is often not known in advance what the maximum size of an +% |l|~column will be. A good solution for this is to use an |X|~specifier, +% typesetting the table at the text width with the \REF{tabularx} package. +% However, this will result in too much white space in cases where the +% column contains small texts only. This problem can be solved by using +% the maxwidth option instead of the width option. The |X|~specifiers will +% then be replaced with |l| as long as the width of the resulting table +% stays with the specified maximum width. +% +% \section{Tables wider than the text width} +% When you make a table wider than |\textwidth|, it will extend in the right margin. +% If it is a large table, occupying a whole page, you can use the geometry package +% and surround your ctable call with |\newgeometry{width=...,margin=...}| and |\restoregeometry|. +% However, both geometry commands imply |\clearpage|, so your table will appear on an otherwise +% empty page. +% +% Alternatively, you can center the table on the paper, extending in both margins, by using the +% option |doinside=\hspace*{<dimen>}| with an appropriate negative |dimen>|. +% +% \section{Setting option defaults: setupctable} +% Every call of |\ctable| resets the options to their defaults before evaluating the +% first (optional) argument. So if you make two ctables: |\ctable[left,...| and +% |\ctable[...|, the first will be left-aligned on the page, but the second, lacking +% the |left| option, will be centered, because that is the default. If you want all +% your tables left-aligned, it's more practical to change the default by calling +% \DescribeMacro{\setupctable} +% |\setupctable{left}|, either in the preamble or somewhere in the body. In latter +% case only tables following the call will have their defaults changed. \par +% |\setupctable| can set the defaults for all options except (of course) |caption|, +% |cap|, and |label|. Actually, the initial option defaults are set by +% calling |\setupctable| as follows: +% \begin{verbatim} +% \setupctable{ +% captionskip=0pt, framerule=0pt, nostar, +% center, framesep=0pt, pos=tbp, +% continued=(continued), maxwidth=0pt, super, +% doinside={}, mincapwidth=0pt, table, +% framebg=1 1 1, nonotespar, topcap, +% framefg=0 0 0, nosideways, width=0pt +% } +% \end{verbatim} +% \section{Other commands} +% \DescribeMacro{\tnote} +% |\tnote[label]{footnote text}| places {\footnotesize +% \textsuperscript{\normalfont\textit{label}}\,footnote text} +% under the table. +% This command can only be used in |\ctable|'s third argument, i.e.\ the foottable +% argument described above. The +% label is optional, the default label is a single $a$. For more +% detailed control, you can also replace this command with something +% like |labeltext&footnotetext\NN|. +% The footnotes are placed under the table, without a rule. +% You therefore probably will want to use the |\LL| (last line) +% command if you use footnotes. +% \par +% \DescribeMacro{\tmark} +% |\tmark[label]| this command places the superscripted label in the +% table. It is equivalent with |$^{label}$|. +% The label is optional, the default label is a single $a$. +% |\tmark| may be used in captions, but only \textit{without} an argument. +% \par +% The newline generating commands are a combination of +% |\tabularnewline| and zero or one of \REF{booktabs} |\toprule|, +% |\midrule| or |\bottomrule|. These combinations have been made, and +% short names have been defined, because source texts for complex +% tables often become very crowded: +% \par +% \DescribeMacro{\NN} Normal Newline, generates just a normal new line. +% An optional dimen parameter inserts extra vertical space under the +% line. Is an alias for |\tabularnewline| +% \par +% \DescribeMacro{\FL} First Line, generates a new line and a thick +% rule with some extra space under it. +% An optional dimen parameter sets the line width; the default is 0.08em. +% Is an alias for |\toprule| +% \par +% \DescribeMacro{\ML} Middle Line: generates a new line and a thin +% rule with some extra space over and under it. +% An optional dimen parameter sets the line width; the default is 0.05em. +% Is an alias for |\tabularnewline\midrule| +% \par +% \DescribeMacro{\LL} Last Line: generates a new line and a thick +% rule with some extra space over it. +% An optional dimen parameter sets the line width; the default is 0.08em. +% Is an alias for |\tabularnewline\bottomrule| +% \par +% These macros can be used outside |\ctable| constructs. +% \par +% Finally, for completeness, here are some of \REF{booktabs}' commands +% that may be useful: +% \par +% \DescribeMacro{\toprule} |\toprule[<wd>]| +% where |<wd>| is the optional thinkness of the rule. +% \par +% \DescribeMacro{\midrule} |\midrule[<wd>]|. +% \par +% \DescribeMacro{\bottomrule} |\bottomrule[<wd>]|. +% \par +% \DescribeMacro{\cmidrule} |\cmidrule[<wd>](<trim>){a-b}| +% where |<trim>| can be |r|, |l|, or |rl| +% and the rule is drawn over columns |a| through |b|. +% \par +% \DescribeMacro{\morecmidrules} |\morecmidrules| +% must be used to separate two successive cmidrules. +% \par +% \DescribeMacro{\addlinespace} |\addlinespace[<wd>]| +% inserts extra space between rows. +% \par +% \DescribeMacro{\specialrule} +% |\specialrule{<wd>}{<abovespace>}{<belowspace>}|. +% \par +% See the \REF{booktabs} documentation for details. +% \newpage +% \section{Examples} +% Table~\ref{nowidth} is an example taken from the related package +% \REF{threeparttable} by Donald Arseneau, with an extra footnote. +% It was typeset with: +% \color{vbgreen} +% \begin{verbatim} +% \ctable[ +% cap = The Skewing Angles, +% caption = The Skewing Angles ($\beta$) for +% $\fam0 Mu(H)+X_2$ and $\fam0 Mu(H)+HX$~\tmark, +% label = nowidth, +% pos = h +% ]{rlcc}{ +% \tnote{for the abstraction reaction, +% $\fam0 Mu+HX \rightarrow MuH+X$.} +% \tnote[b]{1 degree${} = \pi/180$ radians.} +% \tnote[c]{this is a particularly long note, showing that +% footnotes are set in raggedright mode as we don't like +% hyphenation in table footnotes.} +% }{ \FL +% & & $\fam0 H(Mu)+F_2$ & $\fam0 H(Mu)+Cl_2$ \ML +% &$\beta$(H) & $80.9^\circ$\tmark[b] & $83.2^\circ$ \NN +% &$\beta$(Mu) & $86.7^\circ$ & $87.7^\circ$ \LL +% } +% \end{verbatim} +% \color{black} +% \ctable[ +% cap = The Skewing Angles, +% caption = The Skewing Angles ($\beta$) for +% $\fam0 Mu(H)+X_2$ and $\fam0 Mu(H)+HX$~\tmark, +% label = nowidth, +% pos = h +% ]{rlcc}{ +% \tnote{for the abstraction reaction, +% $\fam0 Mu+HX \rightarrow MuH+X$.} +% \tnote[b]{1 degree${} = \pi/180$ radians.} +% \tnote[c]{this is a particularly long note, showing that +% footnotes are set in raggedright mode as we don't like +% hyphenation in table footnotes.} +% }{ \FL +% & & $\fam0 H(Mu)+F_2$ & $\fam0 H(Mu)+Cl_2$ \ML +% &$\beta$(H) & $80.9^\circ$\tmark[b] & $83.2^\circ$ \NN +% &$\beta$(Mu) & $86.7^\circ$ & $87.7^\circ$ \LL +% } +% Table~\ref{width} is an example with a width specification, +% taken from the \REF{tabularx} documentation, with the vertical rules +% removed. +% By using the trimming parameters of the \REF{booktabs} |\cmidrule| +% command, some of the horizontal splitting was regained. +% The |left| option left aligns the table. It was typeset with: +% \color{vbgreen} +% \begin{verbatim} +% \ctable[ +% caption = Example with a specified width of 100mm, +% label = width, +% width = 100mm, +% pos = ht, +% left +% ]{c>{\raggedright}Xc>{\raggedright}X}{ +% \tnote{footnotes are placed under the table} +% }{ \FL +% \multicolumn{4}{c}{Example using tabularx} \ML +% \multicolumn{2}{c}{Multicolumn entry!} & THREE & FOUR \NN +% \cmidrule(r){1-2}\cmidrule(rl){3-3}\cmidrule(l){4-4} +% one& +% The width of this column depends on the width of the table.\tmark & +% three& +% Column four will act in the same way as column two, with the same width.\LL +% } +% \end{verbatim} +% \color{black} +% \ctable[ +% caption = Example with a specified width of 100mm, +% label = width, +% width = 100mm, +% pos = ht, +% left +% ]{c>{\raggedright}Xc>{\raggedright}X}{ +% \tnote{footnotes are placed under the table} +% }{ \FL +% \multicolumn{4}{c}{Example using tabularx} \ML +% \multicolumn{2}{c}{Multicolumn entry!} & THREE & FOUR \NN +% \cmidrule(r){1-2}\cmidrule(rl){3-3}\cmidrule(l){4-4} +% one& +% The width of this column depends on the width of the +% table.\tmark & +% three& +% Column four will act in the same way as +% column two, with the same width. \LL +% } +% +% Figures, even single ones, are always put in tabular cells. This is not +% particularly handy for single pictures, but it eases the construction of +% arrays of pictures, including sub-captions, delineation, and spacing. For a +% small example, which also shows how you can simplify the construction of +% figure arrays, see subsection~\ref{figureexample} on +% page~\pageref{figureexample}. +% +% \section{Option examples} +% In the following, small examples will be shown illustrating the effect of +% options. In the left column the relevant part of the source is shown, in the +% right column you see the result. In most cases you see a standard example on a +% light yellow background, followed by one or more variations on a light blue +% background. Where necessary, the example will show boxes to indicate the page +% and the text body. +% +% \subsection{\ttfamily\bfseries center, left, right} +% These options align the float in the page; the default is |center|: +% \medskip\\ +% \ROW{Y}{s02k}{02k} +% \ROW{B}{s02l}{02l} +% \ROW{B}{s02m}{02m} +% +% \subsection{\ttfamily\bfseries super, nosuper} +% Footnote markers in |ctable| are typeset superscripted by default. Use the +% |nosuper| option to place them on the base line: +% \medskip\\ +% \ROW{Y}{s07a}{07a} +% \ROW{B}{s07b}{07b} +% +% \subsection{\ttfamily\bfseries notespar, nonotespar} +% By default, footnotes in |ctable| are typeset in a table, one line per note. +% This corresponds with the |nonotespar| option.You can also typeset them in a paragraph, +% one after the other, by using the |notespar| option: +% \medskip\\ +% \ROW{Y}{s12a}{12a} +% \ROW{B}{s12b}{12b} +% +% \subsection{\ttfamily\bfseries continued} +% The |continued| option suffixes the caption with ` (continued)', and lowers the table +% number by one, so that it obtains the same number as the previous table. +% This option can be given an argument to replace the default suffix: +% \medskip\\ +% \ROW{Y}{s13a}{13a} +% \ROW{B}{s13b}{13b} +% \ROW{B}{s13c}{13c} +% +% \subsection{\ttfamily\bfseries mincapwidth} +% |ctable| forces caption and footnotes to stay within the width of the table. +% Sometimes, however, tables are so narrow, that this is not really what you want. +% In such cases, use the |mincapwidth| option to give caption and footnotes some +% extra room: +% \medskip\\ +% \ROW{Y}{s05a}{05a} +% \ROW{B}{s05b}{05b} +% \medskip +% You can set |mincapwidth| to a large value, say |\hsize|, if you want a one-line +% caption. Note, however, that this may influence the horizontal positioning of +% the table: values larger than |\hsize| will move a centered table out of the +% center, a value of |\hsize| will prevent the |left| and |right| options to do +% their work, because the table is already captured between the left and right +% margins. When footnotes are small, you may wish to undo the effect of the +% |mincapwidth| option on them: +% \medskip\\ +% \ROW{B}{s05c}{05c} +% \medskip +% +% \subsection{\ttfamily\bfseries maxwidth} +% When \LaTeX-sources containing tables are generated automatically by a +% script, it is often not known in advance what the maximum size of an |l| +% column will be. A good solution for this is to use an |X| specifier, +% typesetting the table at the text width with the \REF{tabularx} package. +% However, this will result in too much white space in cases where the +% column contains small texts only. This problem can be solved by using +% the maxwidth option instead of the width option. The |X| specifiers will +% then be replaced with |l| as long as the width of the resulting table +% stays with the specified maximum width. +% \medskip\\ +% \ROW{Y}{s06a}{06a} +% \ROW{B}{s06b}{06b} +% +% \subsection{\ttfamily\bfseries framerule} +% The following examples show the use of frames and backgrounds. Every table +% is typeset by |ctable| with a frame around it, but the frame is, by default, +% drawn with a zero width line, and is therefore invisible. You can make it +% visible by either changing the linewidth to a positive value or by giving it a +% background color, which will be used to fill the frame. +% +% Here is a simple table without a frame, followed by one with a red, |1pt| thick +% frame: +% \medskip\\ +% \ROW{Y}{s08a}{08a} +% \ROW{B}{s08b}{08b} +% \medskip +% As you see, the frame fits closely to the first (|\FL|) and last (|\LL|) table +% lines. This can be a reason to either remove those lines, or to introduce some +% whitespace between the frame and the table with the |framesep| option: +% \medskip\\ +% \ROW{B}{s09b}{09b} +% \medskip +% And finally, we could also frame the table by giving it a, say, yellow backgound +% instead of a red frame line, or even do both: +% \medskip\\ +% \ROW{Y}{s10a}{10a} +% \ROW{B}{s10b}{10b} +% +% \newpage +% \subsection{\ttfamily\bfseries captionskip} +% The distance between a top caption and the table is \texttt{2ex}, +% but it can be varied with \texttt{captionskip}: +% \medskip\\ +% \ROW{Y}{s03a}{03a} +% \ROW{B}{s03b}{03b} +% \medskip +% This works for bottom caption, too: +% \medskip\\ +% \ROW{Y}{s04a}{04a} +% \ROW{B}{s04b}{04b} +% +% \subsection{\ttfamily\bfseries figure, botcap}\label{figureexample} +% By default, |ctable| generates a table float, but with the |figure| option, a +% figure float is generated instead. The caption stays on top, so if you are +% accustomed to have bottom caption for your figures, you will probably also need +% the |botcap| option: +% \medskip\\ +% \ROW{Y}{s01a}{01a} +% \ROW{B}{s01b}{01b} +% +% \newpage +% \subsection{\ttfamily\bfseries doinside} +% The argument of doinside is supposed to be a command to be run inside, +% just before the tabular or tabularx environment. You can use this, for +% example, for the adjustment of the font size with |\small|: +% \medskip\\ +% \ROW{Y}{s14a}{14a} +% \StopEventually{} +% +% \section{Implementation} +% \begin{macrocode} +\RequirePackage{ifpdf,etoolbox,xcolor,xkeyval,array,tabularx,booktabs,rotating} +% \end{macrocode} +% The transparency package works only in pdf mode, and if the tikz package is not loaded; +% otherwise define a dummy |\transparent| and issue a warning. +% \begin{macrocode} +\ifpdf + \@ifpackageloaded{tikz}{ + \PackageWarning{ctable}{ + Transparency disabled: incompatible with tikz package + } + \def\transparent#1{} + }{ + \RequirePackage{transparent} + } +\else + \PackageWarningNoLine{ctable}{\MessageBreak + Transparency disabled: pdfTeX is not running in PDF mode + } + \def\transparent#1{} +\fi +% \end{macrocode} +% We need to know if the user has loaded tikz after ctable. If so, we have +% loaded the transparent package already, which then will disturb the tikz +% definitions, so we must quit with an error message. +% Some warnings depend on whether the caption package is loaded or not. +% Here a flag is set to remember that. +% \begin{macrocode} +\newif\if@CTcaptionloaded +\AtBeginDocument{ + \makeatletter + \@ifpackageloaded{tikz}{ + \@ifpackageloaded{transparent}{ + \PackageError{ctable}{You must load ctable after tikz}{} + } + }{} + \@ifpackageloaded{caption}{\@CTcaptionloadedtrue}{\@CTcaptionloadedfalse} + \makeatother +} +\def\NN{\tabularnewline} +\def\FL{\toprule} +\def\ML{\NN\midrule} +\def\LL{\NN\bottomrule} +\def\@dfltCTfgcolor#1 #2 #3={\definecolor{@dfltCTframefg}{rgb}{#1,#2,#3}} +\def\@dfltCTbgcolor#1 #2 #3={\definecolor{@dfltCTframebg}{rgb}{#1,#2,#3}} +\def\@CTfgcolor#1 #2 #3={% + \definecolor{@CTframefg}{rgb}{#1,#2,#3} + \def\@CTfgactual{@CTframefg}} +\def\@CTbgcolor#1 #2 #3={% + \definecolor{@CTframebg}{rgb}{#1,#2,#3} + \def\@CTbgactual{@CTframebg}} +\def\@CTtextsuperscript#1{% + \ifx\@CTsuper\@CTtrue\@textsuperscript{#1}\else{\footnotesize#1}\fi +} +% \end{macrocode} +% define a true and a false value +% \begin{macrocode} +\def\@CTtrue{1} +\def\@CTfalse{0} +% \end{macrocode} +% normally we do nothing special inside the float, but that can be changed with the doinside option +% \begin{macrocode} +\def\@CTdoinside{\relax} +% \end{macrocode} +% Need three booleans to remember: +% if we use tabularx, +% if we are running in the memoir class, +% \begin{macrocode} +\newif\if@CTusex +\newif\if@CTinmemoir +\@ifclassloaded{memoir}{\@CTinmemoirtrue}{\@CTinmemoirfalse} +% \end{macrocode} +% Need lots of dimens and their defaults +% \begin{macrocode} +\newdimen\@CTframesep \newdimen\@dfltCTframesep +\newdimen\@CTframerule \newdimen\@dfltCTframerule +\newdimen\@CTwidth \newdimen\@dfltCTwidth +\newdimen\@CTcaptionskip \newdimen\@dfltCTcaptionskip +\newdimen\@CTmaxwidth \newdimen\@dfltCTmaxwidth +\newdimen\@CTmincapwidth \newdimen\@dfltCTmincapwidth +\newdimen\@CTfooterwidth \newdimen\@dfltCTfooterwidth +\newdimen\@CTw % the final width +\newdimen\@CTfloatwidth +\newdimen\@CToldsep +\newdimen\@CToldrule +% \end{macrocode} +% Allocate box registers so that we can determine the widths of the +% tables +% \begin{macrocode} +\newbox\CT@t % tabular saved and measured here +% \end{macrocode} +% Option setting commands from keyval. The table position (here, top, +% bottom, page) gets a special treatment, since \LaTeX\ does not expand +% commands there. So instead of putting things like \texttt{tbp} in a +% command like |\@CTbegin| we put +% |\begin{table}[tbp]| in it. +% \begin{macrocode} + +\define@key{suCT}{bgopacity}{\def\@dfltCTbgopacity{#1}} +\define@key{suCT}{botcap}[]{\let\@dfltCTbotcap\@CTtrue} +\define@key{suCT}{captionsinside}[]{\def\rot@LR{-1} + \if@twoside\@rot@twosidetrue + \else\@rot@twosidefalse\fi} +\define@key{suCT}{captionsleft}[]{\@rot@twosidefalse\def\rot@LR{-1}} +\define@key{suCT}{captionsright}[]{\@rot@twosidefalse\def\rot@LR{0}} +\define@key{suCT}{captionskip}{\@dfltCTcaptionskip=#1} +\define@key{suCT}{center}[]{\let\@dfltCTalign\centering} +\define@key{suCT}{continued}{\def\@dflttextcontinued{#1}} +\define@key{suCT}{doinside}{\def\@dfltCTdoinside{#1}} +\define@key{suCT}{figure}[]{\def\@dfltCTtaborfig{figure}} +\define@key{suCT}{framebg}{\@dfltCTbgcolor#1=} +\define@key{suCT}{framefg}{\@dfltCTfgcolor#1=} +\define@key{suCT}{framerule}{\@dfltCTframerule=#1} +\define@key{suCT}{framesep}{\@dfltCTframesep=#1} +\define@key{suCT}{left}[]{\let\@dfltCTalign\raggedright} +\define@key{suCT}{maxwidth}{\@dfltCTmaxwidth=#1} +\define@key{suCT}{mincapwidth}{\@dfltCTmincapwidth=#1} +\define@key{suCT}{footerwidth}[-1pt]{\@dfltCTfooterwidth=#1} +\define@key{suCT}{nonotespar}[]{\let\@dfltCTnotespar\@CTfalse} +\define@key{suCT}{nosideways}[]{\let\@dfltCTsideways\empty} +\define@key{suCT}{nostar}[]{\def\@dfltCTstarred{}} +\define@key{suCT}{nosuper}[]{\let\@dfltCTsuper\@CTfalse} +\define@key{suCT}{notespar}[]{\let\@dfltCTnotespar\@CTtrue} +\define@key{suCT}{pos}{\def\@dfltCTpos{#1}} +\define@key{suCT}{right}[]{\let\@dfltCTalign\raggedleft} +\define@key{suCT}{sideways}[]{\def\@dfltCTsideways{sideways}} +\define@key{suCT}{star}[]{\def\@dfltCTstarred{*}} +\define@key{suCT}{super}[]{\let\@dfltCTsuper\@CTtrue} +\define@key{suCT}{table}[]{\def\@dfltCTtaborfig{table}} +\define@key{suCT}{topcap}[]{\let\@dfltCTbotcap\@CTfalse} +\define@key{suCT}{width}{\@dfltCTwidth=#1} + +\newcommand{\setupctable}[1]{\setkeys{suCT}{#1}} +\setupctable{ + bgopacity=1, + captionskip=0pt, + center, + continued=(continued), + doinside={}, + footerwidth=0pt, + framebg=1 1 1, + framefg=0 0 0, + framerule=0pt, + framesep=0pt, + maxwidth=0pt, + mincapwidth=0pt, + nonotespar, + nosideways, + nostar, + super, + table, + topcap, + width=0pt, +} + +\define@key{CT}{bgopacity}{\def\@CTbgopacity{#1}} +\define@key{CT}{botcap}[]{\let\@CTbotcap\@CTtrue} +\define@key{CT}{captionskip}{\@CTcaptionskip=#1} +\define@key{CT}{caption}{\def\@CTcaption{#1}} +\define@key{CT}{cap}{\def\@CTcap{#1}} +\define@key{CT}{center}[]{\let\@CTalign\centering} +\define@key{CT}{continued}[\@dflttextcontinued]{\def\@CTcontinued{#1}} +\define@key{CT}{doinside}{\def\@CTdoinside{#1}} +\define@key{CT}{figure}[]{\def\@CTtaborfig{figure}} +\define@key{CT}{framebg}{\@CTbgcolor#1=} +\define@key{CT}{framefg}{\@CTfgcolor#1=} +\define@key{CT}{framerule}{\@CTframerule=#1} +\define@key{CT}{framesep}{\@CTframesep=#1} +\define@key{CT}{label}{\def\@CTlabel{#1}} +\define@key{CT}{left}[]{\let\@CTalign\raggedright} +\define@key{CT}{maxwidth}{\@CTmaxwidth=#1} +\define@key{CT}{mincapwidth}{\@CTmincapwidth=#1} +\define@key{CT}{footerwidth}[-1pt]{\@CTfooterwidth=#1} +\define@key{CT}{nonotespar}[]{\let\@CTnotespar\@CTfalse} +\define@key{CT}{nosideways}[]{\let\@CTsideways\empty} +\define@key{CT}{nostar}[]{\def\@CTstarred{}} +\define@key{CT}{nosuper}[]{\let\@CTsuper\@CTfalse} +\define@key{CT}{notespar}[]{\let\@CTnotespar\@CTtrue} +\define@key{CT}{pos}{\def\@CTpos{#1}\def\@CTbegin{\@CTbeg[#1]}} +\define@key{CT}{right}[]{\let\@CTalign\raggedleft} +\define@key{CT}{sidecap}[]{\let\@CTbotcap\undefined} +\define@key{CT}{sideways}[]{\def\@CTsideways{sideways}} +\define@key{CT}{star}[]{\def\@CTstarred{*}} +\define@key{CT}{super}[]{\let\@CTsuper\@CTtrue} +\define@key{CT}{table}[]{\def\@CTtaborfig{table}} +\define@key{CT}{topcap}[]{\let\@CTbotcap\@CTfalse} +\define@key{CT}{width}{\@CTwidth=#1} +% \end{macrocode} +% A caption will only be generated if the \textsl{caption} option was used, with a +% non-empty value. If so, it goes in the lot/lof, unless the \textsl{cap} option +% specified a different (probably shorter) value for it. A \textsl{cap} option with +% an empty value inhibits a tof/lof entry. +% The |\expandonce| trick below is from Marco Daniel. +% It expands the arguments of |\caption| +% so that the hyperref command |\nameref| works OK. +% See http://tex.stackexchange.com/questions/57396/ +% Note that, in captions, |tmark| may only be used without its optional argument. +% \begin{macrocode} +\def\@CTCaption{ + \ifx\@CTcaption\empty\else + \def\@CTcaptionarg{\ifx\@CTlabel\empty\else\label{\@CTlabel}\fi + \@CTcaption\ \@CTcontinued\strut} + \begingroup + \ifx\@CTcap\empty + \edef\x{\endgroup\noexpand\caption[]{\expandonce\@CTcaptionarg}} + \else + \edef\x{\endgroup\noexpand\caption[\expandonce\@CTcap]% + {\expandonce\@CTcaptionarg}} + \fi + \x + \fi +} +% \end{macrocode} +% Need to redefine X columntype, but the array package would generate a warning. +% So first set the type to be redefined to |\undefined| to suppress the warning. +% Save the standard X type once in the new type Y +% \begin{macrocode} +\newcolumntype{Y}{X} +\def\@CTXcolumntype#1{% + \let\NC@find@X\undefined + \newcolumntype{X}{#1}% +} +\long\def\@CTframe#1#2#3{% + \@CToldsep\fboxsep\fboxsep\@CTframesep% + \@CToldrule\fboxrule\fboxrule\@CTframerule% + \transparent{\@CTbgopacity}% + \fcolorbox{#1}{#2}{\fboxsep\@CToldsep\fboxrule\@CToldrule\transparent{1}#3}% +} +\newcommand{\tnote}[2][a]{% + \ifx\@CTnotespar\@CTtrue% + \@CTtextsuperscript{\normalfont\textit{#1}}\,#2 + \else% + \hbox{\@CTtextsuperscript{\normalfont\textit{#1}}}\NN + \fi +} +\newcommand{\tmark}[1][a]{% + \hbox{\textsuperscript{\normalfont\textit{#1}}}} +\newdimen\@CTcurftwidth +\newcommand{\ctable}[4][]{% + \let\@CTtaborfig \@dfltCTtaborfig + \let\@CTalign \@dfltCTalign + \let\@CTsideways \@dfltCTsideways + \let\@CTcontinued \empty + \let\@CTpos \@dfltCTpos + \let\@CTcaption \empty + \let\@CTcap \undefined + \let\@CTlabel \empty + \let\@CTbotcap \@dfltCTbotcap + \let\@CTstarred \@dfltCTstarred + \let\@CTsuper \@dfltCTsuper + \let\@CTnotespar \@dfltCTnotespar + \let\@CTdoinside \@dfltCTdoinside + \let\@CTbgopacity \@dfltCTbgopacity + \@CTframerule \@dfltCTframerule + \@CTcaptionskip \@dfltCTcaptionskip + \@CTframesep \@dfltCTframesep + \@CTwidth \@dfltCTwidth + \@CTmaxwidth \@dfltCTmaxwidth + \@CTmincapwidth \@dfltCTmincapwidth + \@CTfooterwidth \@dfltCTfooterwidth + \def\@CTfgactual {@dfltCTframefg}% + \def\@CTbgactual {@dfltCTframebg}% + \def\@CTbeg {\begin{\@CTsideways\@CTtaborfig\@CTstarred}}% + \def\@CTbegin {\@CTbeg}% + \def\@CTend {\end{\@CTsideways\@CTtaborfig\@CTstarred}}% + \setkeys{CT}{#1}% +% \end{macrocode} +% Make the short caption equal to the caption if it has not been defined +% \begin{macrocode} + \ifx\@CTcap\undefined\let\@CTcap\@CTcaption\fi +% \end{macrocode} +% Issue a warning if the short caption is empty and the caption package is not loaded +% \begin{macrocode} + \ifx\@CTcap\empty + \if@CTcaptionloaded\else + \PackageWarningNoLine{ctable}{\MessageBreak + An empty cap= option prevents lot/loc entry only\MessageBreak + if the caption package is loaded!} + \fi + \fi +% \end{macrocode} +% Currently, the sidecap option can only be used from within the memoir class; +% here we test if memoir is loaded: +% \begin{macrocode} + \if@CTinmemoir\else + \ifx\@CTbotcap\undefined + \PackageError{ctable}{\MessageBreak + You can, currently, use the sidecap option only with\MessageBreak + memoir documents. Use topcap or botcap only} + \fi + \fi +% \end{macrocode} +% It makes no sense to use \textsl{width} together with \textsl{maxwidth} or +% \textsl{pos} together with \textsl{sideways} +% \begin{macrocode} + \ifdim\@CTwidth=0pt\else + \ifdim\@CTmaxwidth=0pt\else + \PackageError{ctable}{\MessageBreak + You may not use the width and maxwidth options together\MessageBreak + Use either width or maxwidth} + \fi + \fi + \ifx\@CTpos\empty + \ifx\@CTsideways\empty\else + \PackageError{ctable}{\MessageBreak + You may not use the pos and sideways options together\MessageBreak + Rotated tables and figures are always typeset on a separate page} + \fi + \fi +% \end{macrocode} +% It makes no sense to label a captionless table, because the label can't +% be placed, leaving the user wondering why references to the table get a ?? +% \begin{macrocode} + \ifx\@CTcaption\empty + \ifx\@CTlabel\empty\else + \PackageError{ctable}{\MessageBreak + You may not label a captionless table\MessageBreak + Such a label can't be referenced} + \fi + \fi +% \end{macrocode} +% save the table contents in a box, so we can determine its width, +% initially, save the table typeset with the tabular environment: +% \begin{macrocode} + \sbox\CT@t{% + \@CTXcolumntype{l}% temporarily make type X = l + \@CTframe{\@CTfgactual}{\@CTbgactual}{% + \@CTdoinside + \begin{tabular}{#2} + #4% + \end{tabular}% + }% + }% +% \end{macrocode} +% then look if we'll need the tabularx environment: +% \begin{macrocode} + \@CTusexfalse + \ifdim\@CTmaxwidth=0pt + \ifdim\@CTwidth=0pt + \else + \@CTusextrue + \fi + \else + \ifdim\wd\CT@t>\@CTmaxwidth + \@CTusextrue + \fi + \fi +% +% if so, replace tabular with tabularx: +% + \if@CTusex + \sbox\CT@t{% + \@CTXcolumntype{Y}% restore X + \@CTframe{\@CTfgactual}{\@CTbgactual}{% + \@CTdoinside + \begin{tabularx}{\ifdim\@CTwidth>0pt\@CTwidth\else\@CTmaxwidth\fi}{#2} + #4% + \end{tabularx}% + }% + }% + \fi +% \end{macrocode} +% the |CT@t| box now contains the table as we want to typeset it; +% determine its width: +% \begin{macrocode} + \@CTw=\wd\CT@t +% \end{macrocode} +% Now find the width of the float, |\@CTfloatwidth|; everything in it will +% be centered within that width. +% Normally we'll use the width of the table, |\@CTw|, but if the +% mincapwidth, |\@CTmincapwidth| was set wider than the table, that will be used: +% \begin{macrocode} + \@CTfloatwidth=\ifdim\@CTmincapwidth>\@CTw + \@CTmincapwidth + \else + \@CTw + \fi +% \end{macrocode} +% |\@CTbegin| is now defined as something like |\begin{table}[tbp]|. +% \begin{macrocode} + \@CTbegin + \ifx\@CTcontinued\empty\else\addtocounter{\@CTtaborfig}{-1}\fi + \@CTalign + \begin{minipage}{\@CTfloatwidth}\parindent0pt + \ifx\@CTbotcap\@CTfalse\@CTCaption\vskip\@CTcaptionskip\fi + \ifx\@CTbotcap\undefined% + \begin{sidecaption}[\@CTcap]{\@CTcaption}[\@CTlabel] + \fi + \centering{\usebox\CT@t}% insert the tabular + \def\@CTfootnotes{#3}% + \ifx#3\empty\else{% append footnotes, if any +% \end{macrocode} +% Footnotes: if the |footerwidth| is 0pt (the default), typeset the footer as +% wide as the caption (which may be wider than the table because of the +% |mincapwidth| option); if it is -1pt (because |footerwidth| was set without an argument) +% make it as wide as the table; otherwise, give it the width set by the +% |footerwidth| option. +% \begin{macrocode} + \@CTcurftwidth=\ifdim\@CTfooterwidth=-1pt\@CTw\else + \ifdim\@CTfooterwidth=0pt\hsize\else + \@CTfooterwidth\fi\fi + \footnotesize + \ifx\@CTnotespar\@CTtrue% + \\[.2ex] + \begin{minipage}{\@CTcurftwidth}% + #3% + \end{minipage}% + \else% + \\ + \begin{tabularx}{\@CTcurftwidth}{r@{\,}>{\raggedright}X} + #3% + \end{tabularx}% + \fi + } + \fi + \ifx\@CTbotcap\undefined\end{sidecaption}\fi + \ifx\@CTbotcap\@CTtrue\vskip\@CTcaptionskip\@CTCaption\fi + \end{minipage} + \@CTend +} +% \end{macrocode} +% \Finale +\endinput diff --git a/macros/latex/contrib/ctable/ctable.ins b/macros/latex/contrib/ctable/ctable.ins new file mode 100644 index 0000000000..141cb1a6f5 --- /dev/null +++ b/macros/latex/contrib/ctable/ctable.ins @@ -0,0 +1,63 @@ +%% +%% Copyright (C) 2005 by Wybo Dekker <wybo@dekkerdocumenten.nl> +%% +%% This file may be distributed and/or modified under the conditions of +%% the LaTeX Project Public License, either version 1.2 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.2 or later is part of all distributions of LaTeX version +%% 1999/12/01 or later. +%% + +\input docstrip.tex +\keepsilent + +\usedir{tex/latex/ctable} + +\preamble + +This is a generated file. + +Copyright (C) 2005 by Wybo Dekker <wybo@dekkerdocumenten.nl> + +This file may be distributed and/or modified under the conditions of +the LaTeX Project Public License, either version 1.2 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.2 or later is part of all distributions of LaTeX version +1999/12/01 or later. + +\endpreamble + +\generate{\file{ctable.sty}{\from{ctable.dtx}{package}}} + +\obeyspaces +\Msg{**************************************************************} +\Msg{* *} +\Msg{* To finish the installation you have to move the following *} +\Msg{* file into a directory searched by TeX: *} +\Msg{* *} +\Msg{* ctable.sty *} +\Msg{* *} +\Msg{* To produce the documentation: *} +\Msg{* 1. generate the graphics needed by running doit in doc *} +\Msg{* 2. run the file ctable.dtx through LaTeX: *} +\Msg{* *} +\Msg{* pdflatex --interaction=batchmode ctable.dtx > /dev/null *} +\Msg{* makeindex -q -s gglo.ist -o ctable.gls ctable.glo *} +\Msg{* makeindex -q -s gind.ist -o ctable.ind ctable.idx *} +\Msg{* pdflatex --interaction=batchmode ctable.dtx > /dev/null *} +\Msg{* (or maybe adapt the inst script to do that and *} +\Msg{* install everything at the same time) *} +\Msg{* *} +\Msg{* Happy TeXing! *} +\Msg{* *} +\Msg{**************************************************************} + +\endbatchfile diff --git a/macros/latex/contrib/ctable/ctable.pdf b/macros/latex/contrib/ctable/ctable.pdf Binary files differnew file mode 100644 index 0000000000..e46fd6f53a --- /dev/null +++ b/macros/latex/contrib/ctable/ctable.pdf diff --git a/macros/latex/contrib/ctable/doc/01a b/macros/latex/contrib/ctable/doc/01a new file mode 100644 index 0000000000..0e80db425c --- /dev/null +++ b/macros/latex/contrib/ctable/doc/01a @@ -0,0 +1,2 @@ +\ctable[caption = a table]{c}{ +}{\FL Table's first row\LL} diff --git a/macros/latex/contrib/ctable/doc/01b b/macros/latex/contrib/ctable/doc/01b new file mode 100644 index 0000000000..798f951413 --- /dev/null +++ b/macros/latex/contrib/ctable/doc/01b @@ -0,0 +1,11 @@ +\newcommand{\F}[1]{ + \includegraphics[width=\hsize]{#1} +} +\newcolumntype{H}[1]{>{\hsize=#1\hsize}X} +\ctable[ + caption = a figure, + figure, botcap, + width=.4\hsize, +]{H{.4}H{.6}}{}{\FL + \F{penguin}& \F{lion}\LL +} diff --git a/macros/latex/contrib/ctable/doc/02k b/macros/latex/contrib/ctable/doc/02k new file mode 100644 index 0000000000..056aba4b8b --- /dev/null +++ b/macros/latex/contrib/ctable/doc/02k @@ -0,0 +1,3 @@ +\ctable[ + caption = Centered, +]{c}{}{\FL Table's first row\LL} diff --git a/macros/latex/contrib/ctable/doc/02l b/macros/latex/contrib/ctable/doc/02l new file mode 100644 index 0000000000..33d9df6fe6 --- /dev/null +++ b/macros/latex/contrib/ctable/doc/02l @@ -0,0 +1,4 @@ +\ctable[ + caption = Left, + left +]{c}{}{\FL Table's first row\LL} diff --git a/macros/latex/contrib/ctable/doc/02m b/macros/latex/contrib/ctable/doc/02m new file mode 100644 index 0000000000..d5beb91b4d --- /dev/null +++ b/macros/latex/contrib/ctable/doc/02m @@ -0,0 +1,4 @@ +\ctable[ + caption = Right, + right +]{c}{}{\FL Table's first row\LL} diff --git a/macros/latex/contrib/ctable/doc/03a b/macros/latex/contrib/ctable/doc/03a new file mode 100644 index 0000000000..4b3fb78340 --- /dev/null +++ b/macros/latex/contrib/ctable/doc/03a @@ -0,0 +1,3 @@ +\ctable[ + caption = Caption, +]{c}{}{\FL Table's first row\LL} diff --git a/macros/latex/contrib/ctable/doc/03b b/macros/latex/contrib/ctable/doc/03b new file mode 100644 index 0000000000..f374419a3f --- /dev/null +++ b/macros/latex/contrib/ctable/doc/03b @@ -0,0 +1,4 @@ +\ctable[ + caption = Caption, +captionskip = 1ex, +]{c}{}{\FL Table's first row\LL} diff --git a/macros/latex/contrib/ctable/doc/04a b/macros/latex/contrib/ctable/doc/04a new file mode 100644 index 0000000000..08cdac9a4a --- /dev/null +++ b/macros/latex/contrib/ctable/doc/04a @@ -0,0 +1,4 @@ +\ctable[ + caption = Caption, + botcap +]{c}{}{\FL Table's first row\LL} diff --git a/macros/latex/contrib/ctable/doc/04b b/macros/latex/contrib/ctable/doc/04b new file mode 100644 index 0000000000..13139d781b --- /dev/null +++ b/macros/latex/contrib/ctable/doc/04b @@ -0,0 +1,5 @@ +\ctable[ + caption = Caption, +captionskip = -2ex, + botcap +]{c}{}{\FL Table's first row\LL} diff --git a/macros/latex/contrib/ctable/doc/05a b/macros/latex/contrib/ctable/doc/05a new file mode 100644 index 0000000000..525352a3d1 --- /dev/null +++ b/macros/latex/contrib/ctable/doc/05a @@ -0,0 +1,3 @@ +\ctable[ + caption = a lengthy caption +]{c}{}{\FL row1\LL} diff --git a/macros/latex/contrib/ctable/doc/05b b/macros/latex/contrib/ctable/doc/05b new file mode 100644 index 0000000000..9d39045b5f --- /dev/null +++ b/macros/latex/contrib/ctable/doc/05b @@ -0,0 +1,5 @@ +\ctable[ + mincapwidth = 40mm, + caption = a lengthy caption +]{c}{\tnote{this is a footnote}} +{\FL row1\tmark\LL} diff --git a/macros/latex/contrib/ctable/doc/05c b/macros/latex/contrib/ctable/doc/05c new file mode 100644 index 0000000000..494bd3593a --- /dev/null +++ b/macros/latex/contrib/ctable/doc/05c @@ -0,0 +1,6 @@ +\ctable[ + mincapwidth = 40mm, + footerwidth, + caption = a lengthy caption +]{c}{\tnote{footnote}} +{\FL row1\tmark\LL} diff --git a/macros/latex/contrib/ctable/doc/06a b/macros/latex/contrib/ctable/doc/06a new file mode 100644 index 0000000000..53b78d2a75 --- /dev/null +++ b/macros/latex/contrib/ctable/doc/06a @@ -0,0 +1,3 @@ +\ctable[framerule=.1pt, maxwidth=3cm +]{lX}{}{\FL 1 & first row\LL} + diff --git a/macros/latex/contrib/ctable/doc/06b b/macros/latex/contrib/ctable/doc/06b new file mode 100644 index 0000000000..e333228401 --- /dev/null +++ b/macros/latex/contrib/ctable/doc/06b @@ -0,0 +1,3 @@ +\ctable[framerule=.1pt, maxwidth=3cm +]{lX}{}{\FL 1 & test\LL} + diff --git a/macros/latex/contrib/ctable/doc/07a b/macros/latex/contrib/ctable/doc/07a new file mode 100644 index 0000000000..d0e5e9d9ca --- /dev/null +++ b/macros/latex/contrib/ctable/doc/07a @@ -0,0 +1,5 @@ +\ctable{c}{ + \tnote{First footnote} + \tnote[b]{Second footnote} +}{\FL Table's\tmark\ first\tmark[b]\ row\LL} + diff --git a/macros/latex/contrib/ctable/doc/07b b/macros/latex/contrib/ctable/doc/07b new file mode 100644 index 0000000000..4adcd36845 --- /dev/null +++ b/macros/latex/contrib/ctable/doc/07b @@ -0,0 +1,5 @@ +\ctable[nosuper]{c}{ + \tnote[a.]{First footnote} + \tnote[b.]{Second footnote} +}{\FL Table's\tmark\ first\tmark[b]\ row\LL} + diff --git a/macros/latex/contrib/ctable/doc/08a b/macros/latex/contrib/ctable/doc/08a new file mode 100644 index 0000000000..e79af4a90f --- /dev/null +++ b/macros/latex/contrib/ctable/doc/08a @@ -0,0 +1,3 @@ +\ctable[ + caption = Frame, +]{c}{}{\FL Table's first row\LL} diff --git a/macros/latex/contrib/ctable/doc/08b b/macros/latex/contrib/ctable/doc/08b new file mode 100644 index 0000000000..10e78f42d0 --- /dev/null +++ b/macros/latex/contrib/ctable/doc/08b @@ -0,0 +1,5 @@ +\ctable[ + caption = Frame, + framerule = 2pt, + framefg = .8 0 0 +]{c}{}{\FL Table's first row\LL} diff --git a/macros/latex/contrib/ctable/doc/09b b/macros/latex/contrib/ctable/doc/09b new file mode 100644 index 0000000000..80270e12ea --- /dev/null +++ b/macros/latex/contrib/ctable/doc/09b @@ -0,0 +1,7 @@ +\ctable[ + caption = Frame, + framerule = 1pt, + framefg = .8 0 0, + framesep=10pt +]{c}{}{\FL Table's first row\LL} + diff --git a/macros/latex/contrib/ctable/doc/10a b/macros/latex/contrib/ctable/doc/10a new file mode 100644 index 0000000000..e9b244cb77 --- /dev/null +++ b/macros/latex/contrib/ctable/doc/10a @@ -0,0 +1,5 @@ +\ctable[ + caption = Frame, + framebg = 1 1 0, + framesep=10pt +]{c}{}{\FL Table's first row\LL} diff --git a/macros/latex/contrib/ctable/doc/10b b/macros/latex/contrib/ctable/doc/10b new file mode 100644 index 0000000000..386b009a93 --- /dev/null +++ b/macros/latex/contrib/ctable/doc/10b @@ -0,0 +1,8 @@ +\ctable[ + caption = Frame, + framerule = 2pt, + framesep = 5pt, + framebg = 1 1 0, + framefg = 1 0 0, + framesep=10pt +]{c}{}{\FL Table's first row\LL} diff --git a/macros/latex/contrib/ctable/doc/12a b/macros/latex/contrib/ctable/doc/12a new file mode 100644 index 0000000000..5ea6601073 --- /dev/null +++ b/macros/latex/contrib/ctable/doc/12a @@ -0,0 +1,7 @@ +\ctable{c}{ + \tnote{First note} + \tnote[b]{Second note} + \tnote[c]{Third note} +}{\FL Table's\tmark\ first\tmark[b]\ row + with footnotes\tmark[c]\LL} + diff --git a/macros/latex/contrib/ctable/doc/12b b/macros/latex/contrib/ctable/doc/12b new file mode 100644 index 0000000000..a1e2fd49a5 --- /dev/null +++ b/macros/latex/contrib/ctable/doc/12b @@ -0,0 +1,11 @@ +\ctable[notespar]{c}{ + \tnote[a]{First note.} + \tnote[b]{Second note.} + \tnote[c]{Third note, this one is a + little longer and forces a + new line at the end.\\} + \tnote[d]{And here is e very long note: + \input{thuan}} +}{\FL Table's\tmark\ first\tmark[b]\ row + with footnotes\tmark[c]\LL} + diff --git a/macros/latex/contrib/ctable/doc/13a b/macros/latex/contrib/ctable/doc/13a new file mode 100644 index 0000000000..accb3b37bb --- /dev/null +++ b/macros/latex/contrib/ctable/doc/13a @@ -0,0 +1,4 @@ +\ctable[ + caption = Caption, + mincapwidth = 50mm, +]{c}{}{\FL Table's first row\LL} diff --git a/macros/latex/contrib/ctable/doc/13b b/macros/latex/contrib/ctable/doc/13b new file mode 100644 index 0000000000..d57b0659cb --- /dev/null +++ b/macros/latex/contrib/ctable/doc/13b @@ -0,0 +1,6 @@ +\addtocounter{table}{1} % remove for source +\ctable[ + caption = Caption, + mincapwidth = 50mm, + continued +]{c}{}{\FL Table's first row\LL} diff --git a/macros/latex/contrib/ctable/doc/13c b/macros/latex/contrib/ctable/doc/13c new file mode 100644 index 0000000000..71feba3cb6 --- /dev/null +++ b/macros/latex/contrib/ctable/doc/13c @@ -0,0 +1,6 @@ +\addtocounter{table}{1} %remove for source +\ctable[ + caption = Caption, + mincapwidth = 50mm, + continued = \textit{(contd)} +]{c}{}{\FL Table's first row\LL} diff --git a/macros/latex/contrib/ctable/doc/14a b/macros/latex/contrib/ctable/doc/14a new file mode 100644 index 0000000000..15745b30c9 --- /dev/null +++ b/macros/latex/contrib/ctable/doc/14a @@ -0,0 +1,8 @@ +\ctable[ + caption=Doinside, + doinside = \scriptsize]{l}{ +}{\FL + This table has all rows \NN + set at script size \LL +} + diff --git a/macros/latex/contrib/ctable/doc/doit b/macros/latex/contrib/ctable/doc/doit new file mode 100755 index 0000000000..e9d627786d --- /dev/null +++ b/macros/latex/contrib/ctable/doc/doit @@ -0,0 +1,49 @@ +#!/bin/bash + +# doit - make all or some example picture sets. + +# Usage: doit # make them all +# doit nnx # make nnx.pdf and snnx.pdf +# +# pictures are numbered 01, 02, etc. +# nn[a-z] has code to typeset a \ctable; for nn[k-z] page layout will be shown +# for each nn[a-z] two pdfs are generated: +# nn[a-z].pdf for the ctable picture +# and snn[a-z].pdf for the source code verbatim. +# The prefix (s) for source verbatims and (empty) for result files is set by PRE +set=${1:-[0-9][0-9][a-z]} +for j in $set; do + # source verbatim + { cat <<-'EOD' + \documentclass{article} + \usepackage[a4paper,margin=20mm,noheadfoot]{geometry} + \pagestyle{empty} + \begin{document}\ttfamily + \fontsize{10}{12 pt}\selectfont + \begin{verbatim} + EOD + grep -v "remove from source" $j + cat <<-'EOD' + \end{verbatim} + \end{document} + EOD + } >s$j.tex + + mk --noprint --noview s$j.tex >/dev/null && mk -c s$j + pdfcrop s$j.pdf s$j.pdf >& /dev/null + # result + { echo '\documentclass[twoside]{article}' + [[ $j =~ [k-z] ]] && echo '\usepackage[papersize={56mm,40mm},showframe,margin=1mm,noheadfoot]{geometry}' + cat <<-'EOD' + \usepackage{ctable} + \usepackage{txfonts} + \pagestyle{empty} + \parindent0pt + \begin{document} + EOD + cat $j + echo '\end{document}' + } > $j.tex + mk --noprint --noview $j.tex >/dev/null && mk -c $j + pdfcrop $j.pdf $j.pdf >& /dev/null +done diff --git a/macros/latex/contrib/ctable/doc/lion.png b/macros/latex/contrib/ctable/doc/lion.png Binary files differnew file mode 100644 index 0000000000..0026477896 --- /dev/null +++ b/macros/latex/contrib/ctable/doc/lion.png diff --git a/macros/latex/contrib/ctable/doc/penguin.jpg b/macros/latex/contrib/ctable/doc/penguin.jpg Binary files differnew file mode 100644 index 0000000000..342ccda220 --- /dev/null +++ b/macros/latex/contrib/ctable/doc/penguin.jpg diff --git a/macros/latex/contrib/ctable/inst b/macros/latex/contrib/ctable/inst new file mode 100755 index 0000000000..9754480f51 --- /dev/null +++ b/macros/latex/contrib/ctable/inst @@ -0,0 +1,152 @@ +#!/bin/bash + dtxname=ctable + dtxtype=package + ext=sty + delete=($dtxname.$ext README.tex doc/\*.tex) + dtxversion=$(grep " v[0-9.]\+[a-z]\{0,1\} $dtxname $dtxtype" $dtxname.dtx |sed 's/.* v\([0-9.]\+[a-z]\{,1\}\) .*/\1/') +executables=(mk texlog_extract zip getopt pdfseparate pdflatex) + + version=1.00 + myname=$(basename $0) + +<<'DOC' += inst - install ctable + += Synopsis +inst [options] + +Without any options, inst installs ctable in the first writable +TEXMFMAIN, TEXMFLOCAL or TEXMFHOME tree. + +Options: +-h,--help print this help and exit +-H,--Help print full documentation via less and exit +-V,--version print version and exit + + += Description +inst must be run in its own directory (|./inst|) and then does the following: +- generates the documentation for isodoc, +- installs ctable in one of your TeX trees: TEXMFMAIN, TEXMFLOCAL or TEXMFHOME. + The first one writable by you will chosen. +- creates a zip file named |ctable-x.yy.zip| for upload to CTAN +- cleans up + += Author and copyright +Author Wybo Dekker +Email U{wybo@dekkerdocumenten.nl}{wybo@dekkerdocumenten.nl} +License Released under the U{www.gnu.org/copyleft/gpl.html}{GNU General Public License} +DOC + + die() { echo -e "$myname: $Err$@$Nor" 1>&2; exit 1; } + help() { sed -n '/^= Synopsis/,/^= /p' $0|sed '1s/.*/Usage:/;/^= /d'; exit; } +helpall() { sed -n '/^<<.DOC.$/,/^DOC$/p' $0|sed -n '1d;$d;p'|less; exit; } +version() { echo $version; exit; } + +Nor='\e[0m' # reset color ] +Err='\e[31;1m' # light red ] + +setdir() { # create installation directory + for i in MAIN LOCAL HOME; do + tree=$(kpsewhich --expand-var \$TEXMF$i) + test -w $tree && break + tree= + done + [[ -n $tree ]] || die "Could not find a writable TeX tree" + insttex=${tree}/tex/latex/$dtxname + instsrc=$tree/source/latex/$dtxname + instdoc=$tree/doc/latex/$dtxname + mkdir -p $insttex || die could not create $insttex + mkdir -p $instsrc || die could not create $instsrc + mkdir -p $instdoc || die could not create $instdoc +} + +testexecs() { # test presence of executables + for i in ${executables[*]}; do + type $i &> /dev/null || die executable $i not found + done +} + +readme() { # generate the README file +sed -n '/^%<\*readme>/,/^%<\/readme>/p + /\\changes{v'$dtxversion'}/,/^% }/p' $dtxname.dtx | +sed 's/^%//;s/\\\\$// + / Author:/i\ +Version:| '$dtxversion' + /<.readme>/d + /^ }/d + s/ \\changes.*/Changes in version '$dtxversion':/ + s/$\\Rightarrow\$/=>/g + s/\\textbackslash/\\/g + s/\\text\(sl\|it\){\([^}]\+\)}/\/\2\//g # \textsl{...} -> /.../ + s/{\([^}]*\)}/\1/g # keep last, removes all {...} + ' >README + grep "Changes in version" README >/dev/null || die changes not detected +} + +makeall() { + grep '%<\*install>' $dtxname.dtx >/dev/null && # for self-extracting dtx files + delete+=($dtxname.ins) || + echo y |tex $dtxname.ins >/dev/null + + # install any .ttf files + mkdir -p ~/.fonts + find doc -name '*.ttf' -exec cp {} ~/.fonts \; + fc-cache ~/.fonts + + readme # create the README file + + # compile all examples + cd doc + ln -sf ../$dtxname.sty || exit 1 # use the version to be installed + for i in [0-9][0-9]?; do + if [ ! -f $i.pdf -o ! -f s$i.pdf ]; then + ./doit || exit 1 + break + fi + done + cd .. + + mk --noprint --noview $dtxname.dtx && mk -c $dtxname.dtx # make $dtxname.pdf +} + +installall() { + # install and cleanup + echo installing in $tree + + rm -rf $insttex/* $instsrc/* $instdoc/* + find doc \( -type l -o -name '*.pdf' \) -delete + cp -f $dtxname.$ext $insttex + cp -a $dtxname.{ins,dtx} $instsrc + cp -a README inst $dtxname.pdf $instdoc + mktexlsr $tree 2>/dev/null + for i in ${delete[@]}; do rm -f $i; done + cd .. + zipfile=$dtxname/$dtxname-$dtxversion.zip + rm -f $zipfile + zip -rq $zipfile $dtxname/* -x $dtxname/test\* + cd $dtxname +} + +options=$(getopt \ + -n $myname \ + -o hHV \ + -l help,Help,version \ + -- "$@" +) || exit 1 +eval set -- "$options" +while [ $# -gt 0 ]; do + case $1 in + (-h|--help) help;; + (-H|--Help) helpall;; + (-V|--version) version;; + (--) shift; break;; + (*) break;; + esac +done +[[ -z $1 ]] || die No arguments expected + +testexecs +setdir +makeall +installall |