I originally thought this had to do with the align environment but I discovered it's a feature of \halign
, hence the major edit.
When inside a tabular environment or simple halign, I need to be able to pass parts of it (spanning multiple columns and rows) to a macro which would process it and put it right back (for a simple example, place some delimiter on the right and left of the content). It works except when there is something typeset before the macro in the same cell. Here's a MWE:
\documentclass{article}
\def\foo#1\bar{$\rightarrow$ #1 $\leftarrow$}
\begin{document}
\halign{ # & # \cr
\foo foo & bar \bar \cr
%
\foo foo & bar \cr
foo & bar \bar \cr
%
foo \foo foo \bar & \foo bar \bar \cr
% foo \foo foo & bar \bar \cr % error 'Forbidden control sequence found while scanning use of \foo'
}
\end{document}
Using a non-delimited macro like \def\foo#1{ whathever #1}
I cannot span multiple rows (I can't pass it \cr even if I define it as \long
). Can I achieve what I want using an environment, if so---how?
P.S. What I'm trying to do is find a flexible solution to put a fancy frame certain parts of equations inside an ams align environment and I decided to write my own in TikZ following @Marco Daniel's example in How to box two lines inside align*. In the end, I need to grab the whole content of the framed box (which may start anywhere within a cell, and span multiple cells and rows), so I can calculate it's height and depth properly.
tikzmark
here?