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}
environwhich captures the contents of the environment in a macro\BODY. However, you need\multicolumnto 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)? – Werner Oct 2 '12 at 23:51\parboxwhich isminipagethen you can put\begin{minipage}in your start code and\end{minipage}in the code and so keep braces balanced. In the case ofmulticolumnuse thelrboxenvironment as above to save the parbox and then use \multicolumn{}{..\usebox...}` in the end code to use the collected text. – David Carlisle Oct 2 '12 at 23:59\multicolumninside the\beginpart of an environment. It executes\begingroupquite at the beginning before the start code of the environment is executed.\begingroupdestroys the possibility for\multicolumn. – Heiko Oberdiek Oct 3 '12 at 0:47