1

Is there a way to automatically create a macro for all the content of each cell in a table? For example, if I have the following table

    \begin{tabular}{cc}
        this_is_cell-r1c1  & this_is_cell-r1c2 \\
        this_is_cell-r2c1 & this_is_cell-r2c2 \\
    \end{tabular}

I would like to be able to call each cell with a macro. For instance, the content of the cell in the row1 and column 1 is \r1c1. Where \r1c1 should return the content of the first cell of the table (i.e., this_is_cell-r1c1)

2
  • Out of interest, how do you define \r1c1?
    – Werner
    Commented Sep 4, 2019 at 16:56
  • Sorry, obviously I am not clear enough. What I would like is that a macro for each cell is automatically defined, i.e., whenever I create a cell (e.g., r1c1) a macro is automatically created (e.g., \r1c1). Please shout if still unclear
    – augusto
    Commented Sep 4, 2019 at 16:58

1 Answer 1

1

While TABstacks are not as versatile as tabulars, they do provide the requested feature of individual cell referencing.

\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}

enter image description here

2
  • Brilliant! that completely solves my problem! I guess I was too stuck in tables
    – augusto
    Commented Sep 4, 2019 at 17:08
  • @augusto I'm glad it worked out for you. Commented Sep 4, 2019 at 17:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .