I have a table where I have to execute the same command for every entry in the table. For example:
\ibibleverse{Matthew}(1:1) & \ibibleverse{Mark}(1:1) & \ibibleverse{Luke}(1:1) \\
\ibibleverse{Matthew}(1:2) & \ibibleverse{Mark}(1:2) & \ibibleverse{Luke}(1:2) \\
\ibibleverse{Matthew}(1:3) & \ibibleverse{Mark}(1:3) & \ibibleverse{Luke}(1:3) \etc.
Is there a way that I can make every entry in the column automatically execute the \ibibleverse
command so that my table syntax can look like this instead:
1:1 & 1:1 & 1:1 \\
1:2 & 1:2 & 1:2 \\
1:3 & 1:3 & 1:3 \
The parentheses are part of the \ibibleverse
command. The full command looks like \ibibleverse{Matthew}(1:1)
and outputs "Matthew 1:1".
Of course, the header of the table should not have the \ibibleverse
command.
Does this even make sense? Is it possible without repeating, by hand, \ibibleverse
so many times?
Best Answer
You can use the
collcell
package to collect the cell of each row and apply the appropriate macro to the column. Below I defined the columns typeW
to apply to apply\ibibleverse{Matthew}{#1}
macro,K
column type to apply\ibibleverse{Mark}{#1}
, and theE
column type to apply\ibibleverse{Luke}{#1}
(column names based on the last characters ofMatthew
,Mark
, andLuke
.Code:
If you want to exclude header tows you can use the solution from Tables header row's: how to ignore the column type? to only apply these macros in you are not in a header row.
Code: