Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!noose.ecn.purdue.edu!mentor.cc.purdue.edu!purdue!haven!umbc3!math13.math.umbc.edu!rouben From: rouben@math13.math.umbc.edu (Rouben Rostamian) Newsgroups: comp.text.tex Subject: Re: How do I comment-out a block of TeX Message-ID: <4881@umbc3.UMBC.EDU> Date: 24 Jan 91 03:54:36 GMT References: <29555@usc> Sender: newspost@umbc3.UMBC.EDU Reply-To: rouben@math13.math.umbc.edu.UUCP (Rouben Rostamian) Distribution: comp Organization: Mathematics Department University of Maryland, Baltimore County Lines: 62 In article <29555@usc> siemsen@sol.usc.edu (Pete Siemsen) writes: >Is there some way to comment out a block of TeX code? Yes, I can >insert a percent sign at the front of every line, but I want something >simpler, like C's "#if 0" and "#endif" preprocessor directives. I >tried \ifnum0>1 ... \fi, but TeX barfed with "missing \fi" after 2000 >or so lines. I do not know off hand how to define an \comment macro in TeX, but I recall a discussion of this issue in TeXHaX or someplace like that, and that there were some people who offered solutions which I did not save. I cannot imagine why you should want to comment-out 2000 lines of text out of a file. Two thousand lines of text should never be placed in one file to begin with. I have two suggestion regarding your query: 1. The longer a TeX file, the more unwieldy it gets, not only for debugging, but for editing, TeXing, updating, revising, spell-checking, and so on. I always advise beginners to break up their TeX files into as many logically separate components as possible. For instance, when writing a journal article, it is a good idea to place each section, not matter how short, into a separate file. Then have a master file \input the individual sections for processing. The same method applies to chapters and subsections of books and monographs. After all, "modular programming" is the standard practice in writing programs, and a TeX documents is not much different from a program. Once you have modularized your text, you can comment and uncomment selected \input commands in the master file to process individual sections. 2. If you are on a machine with a C compiler, you may use C preprocessor's #ifdef construct to comment out sections of a TeX document. Just enclose the selected text within an "#ifdef DEBUG" and "#endif", and run your TeX document through the C preprocessor before feeding it to TeX. The C preprocesor is accessed differently depending on the particular machine you are on. Consult the manual. In ultrix, you may do: /lib/ccp -P -DDEBUG file.tex >file_new.tex End of suggestions. ----------------------------------------------------------------------- \begin{wishlist} I wish that the unix implementation of TeX would accepts files form standard in, as most other unix utilities do. In that case I could by-pass the creation of the intermediate file_new.tex in the example above and do: /lib/ccp -P -DDEBUG file.tex |latex Alas, ... \end{wishlist} -- Rouben Rostamian Telephone: (301) 455-2458 Department of Mathematics and Statistics e-mail: University of Maryland Baltimore County bitnet: rostamian@umbc.bitnet Baltimore, MD 21228, U.S.A. internet: rouben@math9.math.umbc.edu