![如何为表中的每个单元格自动创建一个宏](https://linux22.com/image/401259/%E5%A6%82%E4%BD%95%E4%B8%BA%E8%A1%A8%E4%B8%AD%E7%9A%84%E6%AF%8F%E4%B8%AA%E5%8D%95%E5%85%83%E6%A0%BC%E8%87%AA%E5%8A%A8%E5%88%9B%E5%BB%BA%E4%B8%80%E4%B8%AA%E5%AE%8F.png)
有没有办法自动为表格中每个单元格的所有内容创建宏?例如,如果我有以下表格
\begin{tabular}{cc}
this_is_cell-r1c1 & this_is_cell-r1c2 \\
this_is_cell-r2c1 & this_is_cell-r2c2 \\
\end{tabular}
我希望能够使用宏调用每个单元格。例如,第 1 行第 1 列的单元格内容为 \r1c1。其中 \r1c1 应返回表格第一个单元格的内容(即 this_is_cell-r1c1)
答案1
尽管 TABstacks 不像tabular
s 那样多功能,但它们确实提供了所请求的单独单元格引用功能。
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{tabstackengine}
\TABstackMath
\TABstackMathstyle{\displaystyle}
\begin{document}
\setstackgap{L}{20pt}
\tabularCenterstack{cc}{
C_{11} & \frac{C_{12}^{x^x}}{\pi} \\
\ldots \textrm{and} & C_{22}
}
For the most recently rendered TAB-stack...
The rendered cell at position (1,2) is: \TABcell{1}{2}
The raw tokens in cell (2,1) are: \getTABcelltoks[2,1]
\detokenize\expandafter{\the\TABcelltoks}
Cell (1,1) may also be rendered with its vertical and horizontal
struts intact (here shown in a box):
\fboxsep=-\fboxrule\relax
\fbox{\TABcellBox{1}{1}}
\end{document}