| 1 |
The collcell Package |
| 2 |
-------------------- |
| 3 |
Copyright (c) 2009-2025 by Martin Scharrer <[email protected]> |
| 4 |
CTAN: http://www.ctan.org/pkg/collcell/ |
| 5 |
Code repository: https://github.com/MartinScharrer/collcell/ |
| 6 |
|
| 7 |
This package provides macros which collect the cell content of |
| 8 |
a tabular and provide it to a macro as argument. It was inspired by the |
| 9 |
\collect@body macro defined by the amsmath or the environ package, |
| 10 |
which can be used to collect the body of an environment. Special care |
| 11 |
is taken to remove all aligning macros inserted by tabular from the cell |
| 12 |
content. The macros also work in the last column of a table. They do not |
| 13 |
support verbatim material inside the cells. |
| 14 |
|
| 15 |
|
| 16 |
Usage |
| 17 |
|
| 18 |
This package provides the macros \collectcell and \endcollectcell which are |
| 19 |
supposed to be used with the >{ } and <{ } tabular column declarations of the |
| 20 |
array package. This can be done either in the argument of tabular or using |
| 21 |
\newcolumntype. |
| 22 |
|
| 23 |
The following code defines a 'E' column which passes the contents of its cell to |
| 24 |
\usermacro as an argument. The macro can the process the content as usual. |
| 25 |
|
| 26 |
% Preamble: |
| 27 |
\usepackage{array} |
| 28 |
\usepackage{collcell} |
| 29 |
% Preamble or document: |
| 30 |
\newcolumntype{E}{>{\collectmacro\usermacro}c<{\endcollectmacro}} |
| 31 |
% Document: |
| 32 |
\begin{tabular}{lE} |
| 33 |
A & Example \\ % Same as \usermacro{Example} |
| 34 |
B & Text \\ % Same as \usermacro{Text} |
| 35 |
\end{tabular} |
| 36 |
|
| 37 |
For example \usermacro could be \fbox and wrap the cell content in a frame box. |
| 38 |
More complicated macros are also supported as long they take one argument. This |
| 39 |
package was originally programmed to be used with the \tikztiming macro of the |
| 40 |
tikz-timing package. This macro takes some complex user input and draws a timing |
| 41 |
diagram from it |
| 42 |
|
| 43 |
Note that if such a cell contains a tabular environment by itself, the |
| 44 |
environment must be wrapped in braces '{ }' to ensure proper operation. |
| 45 |
|