I have a command as follows:
\newcommand{\Comment}[1]{&&\tabularnewline\hline} And now I want to convert it to be an environment as follows:
\newsavebox{\tempDescription} \newenvironment{Description} {% \begin{lrbox}{\tempDescription}% \ignorespaces% } {% \end{tempDescription}% &&&\usebox{\tempDescription}\tabularnewline\hline% } The complete code is given below:
\documentclass[dvips,dvipsnames,rgb,table]{book} \usepackage[a4paper,hmargin=10mm,vmargin=40mm,showframe]{geometry} \usepackage{longtable} \usepackage{array} \usepackage{calc} \usepackage{lscape} \setlength{\tabcolsep}{10pt} \setlength{\arrayrulewidth}{1pt} \newcounter{No} \renewcommand{\theNo}{\arabic{No}} \newenvironment{MyTable}[4]% {% \newcolumntype{O}[1]% {% >{% \begin{minipage}% {% ##1\linewidth-2\tabcolsep-1.5\arrayrulewidth% }% \vspace{\tabcolsep}% }% c% <{% \vspace{\tabcolsep}% \end{minipage}% }% }% \newcolumntype{I}[1]% {% >{% \begin{minipage}% {% ##1\linewidth-2\tabcolsep-\arrayrulewidth% }% \vspace{\tabcolsep}% }% c% <{% \vspace{\tabcolsep}% \end{minipage}% }% }% \setcounter{No}{0}%comment out this if you want to continuous numbering for all tables. \begin{longtable}% {% |>{\stepcounter{No}\centering\scriptsize\theNo}O{#1}<{}% |>{\centering}I{#2}<{\input{\jobname.tmp}}% |>{\centering\lstinputlisting{\jobname.tmp}}I{#3}<{}% |>{\scriptsize}O{#4}<{}% |% }% \hline\ignorespaces% }% {% \end{longtable}% } \newcommand{\Comment}[1]{&&\tabularnewline\hline} \newsavebox{\tempDescription} \newenvironment{Description} {% \begin{lrbox}{\tempDescription}% \ignorespaces% } {% \end{tempDescription}% &&&\usebox{\tempDescription}\tabularnewline\hline% } \usepackage{listings} \lstset{% language={PSTricks}, breaklines=true, basicstyle=\ttfamily\scriptsize,% keywordstyle=\color{blue}, backgroundcolor=\color{yellow!30}% } \usepackage{fancyvrb} \def\MyRow{% \VerbatimEnvironment% \begin{VerbatimOut}{\jobname.tmp}% } \def\endMyRow{% \end{VerbatimOut}% } \usepackage{pstricks,pst-node} \newpsstyle{gridstyle}{% gridwidth=0.4pt,%default: 0.8pt gridcolor=Red!20,%default: black griddots=0,%default: 0 % gridlabels=3pt,%default: 10pt gridlabelcolor=Blue,%default: black % subgriddiv=5,%default: 5 subgridwidth=0.2pt,%default: 0.4pt subgridcolor=Green!20,%default: gray subgriddots=0%default: 0 } \usepackage{lipsum} \begin{document} %\clearpage %\pagestyle{empty} %Landscape starts here. %\begin{landscape} \arrayrulecolor{Red} \begin{MyTable}{0.05}{0.3}{0.3}{0.35}% %============= \begin{MyRow} \pspicture*[showgrid](3,3) \pnode(1,1){A} \pnode(3,3){B} \ncline{A}{B} \endpspicture \end{MyRow} \Comment{\lipsum[1]} %============= \begin{MyRow} \begin{pspicture}[showgrid](3,3) \psframe*[linecolor=red!30](3,2) \end{pspicture} \end{MyRow} \Comment{\lipsum[2]} %============= \begin{MyRow} \pspicture[showgrid](3,3) \psframe*[linecolor=green!30](3,2) \endpspicture \end{MyRow} \Comment{\lipsum[3]} %============= \begin{MyRow} \pspicture[showgrid](3,3) \psframe*[linecolor=Yellow](3,2) \endpspicture \end{MyRow} \Comment{% \begin{equation} \int_a^b f(x)\, \textrm{d}x=F(b)-F(a) \end{equation} is the fundamental theorem of calculus. } %============= \begin{MyRow} \pspicture[showgrid](3,3) \psframe*[linecolor=Maroon!30](3,2) \endpspicture \end{MyRow} \begin{Description}%{% Today I ate burnt bread. It was so delicious. \begin{equation} \int_a^b f(x)\, \textrm{d}x=F(b)-F(a) \end{equation} is the fundamental theorem of calculus. %} \end{Description} %============= \end{MyTable} %\end{landscape} %Landscape stops here. %\pagestyle{plain} \end{document} Why cannot it be converted?