Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!julius.cs.uiuc.edu!ux1.cso.uiuc.edu!csrd.uiuc.edu!s41.csrd.uiuc.edu!eijkhout From: eijkhout@s41.csrd.uiuc.edu (Victor Eijkhout) Newsgroups: comp.text.tex Subject: Re: How do I comment-out a block of TeX Message-ID: <1991Jan24.160635.14332@csrd.uiuc.edu> Date: 24 Jan 91 16:06:35 GMT References: <29555@usc> Sender: news@csrd.uiuc.edu (news) Distribution: comp Organization: UIUC Center for Supercomputing Research and Development Lines: 60 siemsen@sol.usc.edu (Pete Siemsen) writes: >Is there some way to comment out a block of TeX code? Yes, I can Here is something I wrote, and posted on both usenet and TeXhax a while ago. It works with plain TeX and LaTeX, and does not suffer from all of the drawbacks of simpler approaches. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Comment.sty version 1.0 2 November 1990 % to be used with plain TeX or LaTeX % % Author % Victor Eijkhout % Center for Supercomputing Research and Development % University of Illinois at Urbana-Champaign % 305 Talbot Lab % 104 South Wright Street % Urbana, Illinois 61801, USA % % eijkhout@csrd.uiuc.edu % % Usage: all text included in between % \comment ... \endcomment % or \begin{comment} ... \end{comment} % is discarded. The closing command should appear on a line % of its own. No starting spaces, nothing after it. % This environment should work with arbitrary amounts % of comment. % % Basic approach: take every line in verbatim mode as macro % argument, then don't do nothing with. \def\makeinnocent#1{\catcode`#1=12 } \def\comment{\begingroup \let\do\makeinnocent \dospecials \makeinnocent\^^L % and whatever other special cases \endlinechar`\^^M \catcode`\^^M=12 \xcomment} {\catcode`\^^M=12 \endlinechar=-1 % \gdef\xcomment#1^^M{\def\test{#1} \ifx\test\plainendcommenttest \let\next\endgroup \else\ifx\test\lalaendcommenttest \def\next{\endgroup\end{comment}} \else \let\next\xcomment \fi \fi \next} } {\escapechar=-1 \xdef\plainendcommenttest{\string\\endcomment} \xdef\lalaendcommenttest{\string\\end\string\{comment\string\}} } \endinput Share and enjoy! Victor.