I want to apply a macro to all the cells of a column with the cell content as the input to the macro. Is this possible?
For example if the cell contents have the word TEST, the macro should take TEST as its argument.
It should be as simple as:
For Yiannis's comment to apply the macro only to the first column, change the preamble (
Ofcourse, you don't need to repeat anything if you don't want to.
You can use the relatively new
Make sure you use the version 2011/02/27 (or later) which contains a lot of improvements.
There is also the possibility to do it the following way, which compiles faster than
You can do this by using the
For example we can define a macro
We can then define a new column type as:
and our minimal example would be:
Please note that this approach involves delimited macros, in this case the space after the word in the table acts to tell the command that it must only read up to there and obviously will fail if there are more than one word as Martin pointed out. One could use other types of delimiters perhaps a
EDIT: added support for
This solution is more or less a LaTeX version of @morbusg's plain TeX answer.
To give an idea of what's going on, let's look at the preamble constructed in the case of the column specification
Caveat: if the last column specifier is that
Perhaps analogous to @Martin's answer, you can box the cell contents using an
The restriction is mainly reliant on what can be boxed by the