Suppose I have this sort of expression in a document.
\multicolumn{8}{l}{%
\parbox{25em}{%
\begin{itemize}
\addtolength{\itemsep}{-1em}
\item foo
\item bar
\end{itemize}%
}}
I'd like to define a new environment, call it "comment" that would allow me to simple write
\begin{comment}
\item foo
\item bar
\end{comment}
and produce the same output. The problem I've encountered is that the parentheses that are opened at the start are only balanced at the very end. That creates a problem if I try to define the "begin"-section of the new environment in the flatfooted way:
\newenvironment{comment}{%
\multicolumn{8}{l}{%
\parbox{25em}{%
\begin{itemize}
\addtolength{\itemsep}{-1em}
}
The parentheses are unbalanced right now, and if I were to balance them inside the definition of the "begin" part of the environment, I'd get the wrong result.
Here's an MWE
\documentclass{article}
\def\Boxes{%
$\Box$ & $\Box$ & $\Box$ & $\Box$ & $\Box$ & $\Box$ & $\Box$%
}
\usepackage{fullpage}
\begin{document}
\begin{table}[h!]
\begin{tabular}{l|ccccccc}
& Tue & Wed & Thur & Fri & Sat & Sun & Mon\\
\hspace{1em}B$^{\flat}$ Major & \Boxes\\
\multicolumn{8}{l}{%
\parbox{25em}{%
\begin{itemize}
\addtolength{\itemsep}{-1em}
\item foo
\item bar
\end{itemize}%
}}
\\
\end{tabular}
\end{table}
\end{document}
environ
which captures the contents of the environment in a macro\BODY
. However, you need\multicolumn
to be the first element in a cell. Can you show a use-case of your requirement in the form of a minimal working example (MWE)?\parbox
which isminipage
then you can put\begin{minipage}
in your start code and\end{minipage}
in the code and so keep braces balanced. In the case ofmulticolumn
use thelrbox
environment as above to save the parbox and then use \multicolumn{}{..\usebox...}` in the end code to use the collected text.\multicolumn
inside the\begin
part of an environment. It executes\begingroup
quite at the beginning before the start code of the environment is executed.\begingroup
destroys the possibility for\multicolumn
.