I have an environment whose behavior depends some outer circumstances. In some cases, the environment should act as a table cell (and in other cases it should act as a paragraph). The appropriate \begin{tabular}{...} and \end{tabular} are printed by another macros, which also change their behavior appropriately.
However, I can't define the appropriate environment. The MWE is:
\documentclass{article}
\newenvironment{cell}{}{&}
\begin{document}
\begin{tabular}{lll}
\begin{cell}
abc
\end{cell}
\end{tabular}
\end{document}
What am I doing wrong and how can I fix it?
&has to be actually seen by the tabular, and not merely produced by some intermediate macro/environment. Thus, you would need\newenvironment{cell}{}{}and\begin{tabular}{lll} \begin{cell} abc \end{cell}&& \end{tabular}– Steven B. Segletes Aug 25 '23 at 22:14\halign/tabularand make your environment produce boxes of known size that you can stack to make an alignment – David Carlisle Aug 25 '23 at 23:06