summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/collcell/README
blob: 8201f91aa2ebb294383a1f6849b50e6c88e667e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
The collcell Package
--------------------
Copyright (C) 2009-2011 by Martin Scharrer <martin@scharrer-online.de>
http://www.ctan.org/pkg/collcell/

This package provides macros which collect the cell content of
a tabular and provide it to a macro as argument. It was inspired by the
\collect@body macro defined by the amsmath or the environ package,
which can be used to collect the body of an environment. Special care
is taken to remove all aligning macros inserted by tabular from the cell
content. The macros also work in the last column of a table. They do not
support verbatim material inside the cells.


Usage

This package provides the macros \collectcell and \endcollectcell which are
supposed to be used with the >{ } and <{ } tabular column declarations of the
array package. This can be done either in the argument of tabular or using
\newcolumntype.

The following code defines a 'E' column which passes the contents of its cell to
\usermacro as an argument. The macro can the process the content as usual.

% Preamble:
\usepackage{array}
\usepackage{collcell}
% Preamble or document:
\newcolumntype{E}{>{\collectmacro\usermacro}c<{\endcollectmacro}}
% Document:
\begin{tabular}{lE}
A & Example \\ % Same as \usermacro{Example}
B & Text    \\ % Same as \usermacro{Text}
\end{tabular}

For example \usermacro could be \fbox and wrap the cell content in a frame box.
More complicated macros are also supported as long they take one argument. This
package was originally programmed to be used with the \tikztiming macro of the
tikz-timing package. This macro takes some complex user input and draws a timing
diagram from it

Note that if such a cell contains a tabular environment by itself, the
environment must be wrapped in braces '{ }' to ensure proper operation.