Path: utzoo!attcan!uunet!olivea!mintaka!bloom-beacon!eru!hagbard!sunic!dkuug!iesd!iesd.auc.dk!krab From: krab@iesd.auc.dk (Kresten Krab Thorup) Newsgroups: comp.text.tex Subject: Re: How do I comment-out a block of TeX Message-ID: Date: 24 Jan 91 16:14:05 GMT References: <29555@usc> Sender: news@iesd.auc.dk (UseNet News) Distribution: comp Organization: Mathematics and Computer Science, University of Aalborg Lines: 105 In-reply-to: siemsen@sol.usc.edu's message of 24 Jan 91 00:29:15 GMT Here's the comment environment from TeXhax-72,1990 /Kresten -------forwarded message follows this line--------- Date: Fri, 02 Nov 90 21:25:51 -0600 From: eijkhout@csrd.uiuc.edu Subject: comment environment Keywords: comment environment Over the last few weeks I have seen two of three requests for a comment environment on the net. Time for action. Probably everyone knows why \def\comment#1\endcomment{} does not work: unbalanced braces, buffer overflow, outer macros, ... I saw one quite ingenious solution of someone who make almost every character into comment. Cute. It will take quite a while before you run into buffer overflow then. Here is another solution: every line is read as verbatim text, and just thrown away. No buffer problems. Never. These macros can be used with plain TeX and LateX, and probably any other macro package. For plain TeX write \comment ... \endcomment For LaTeX write \begin{comment} ... \end{comment} In both cases put the closing command on a line of its own, and nothing before or after it. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % 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 Victor Eijkhout phone: +1 217 244-0047 Center for Supercomputing Research and Development University of Illinois at Urbana-Champaign 305 Talbot laboratory 104 South Wright street Urbana, Illinois 61801-2932, USA home: 2503 W. Springfield Av, Apt. K-4, Champaign 61821, USA -- ( . (. ) ) ) ( ( .________. | | __| | )) Kresten Krab Thorup | | //| Institute for electronic systems `---`-`------'---' Dept. of mathemathics and computer science Coffee coffee ... (C) 1991 Aalborg University - Denmark, EC