Path: utzoo!attcan!uunet!snorkelwacker!usc!ucsd!helios.ee.lbl.gov!pasteur!ucbvax!shum.huji.ac.il!shaig From: shaig@shum.huji.ac.il (Shai Guday) Newsgroups: comp.text Subject: Re: Typesetting programming languages in LaTeX Message-ID: <667@shuldig.Huji.Ac.IL> Date: 27 Feb 90 09:24:49 GMT References: <4285@jhunix.HCF.JHU.EDU> Sender: daemon@ucbvax.BERKELEY.EDU Reply-To: shum!shaig@jade.berkeley.edu (Shai Guday) Organization: Hebrew University of Jerusalem, ISRAEL Lines: 43 In article <4285@jhunix.HCF.JHU.EDU> barrett@jhunix.HCF.JHU.EDU (Dan Barrett) wr ites: % % For the computer programming courses I teach, I make a lot of %handouts that contain code in C, Pascal, LISP, etc. I would like to %have a nice way to typeset these languages in LaTeX. One solution that might be appropriate for a full page of code is to use one of the code printing programs such as vgrind, cprint, or pps. This would be best in those cases where the code segment of the handout does not need further LaTeX text but can be "standalone". If the code should be embedded in LaTeX then I am currently working on a "C" program using lex to parse "C" code, set special words in boldface, and numbers to italics. The LaTeX .sty file for the above is already complete. % The major problems are: % % o Not interpreting symbols of the language as LaTeX symbols; The reason for the use of lex. % o Handling TAB's. % %For the time being, I use the "verbatim" environment. However, it doesn't %understand TAB characters; I have to substitute 8 space characters for %my TAB's (and this isn't always correct). You must understand that LaTeX does not use, by default, fixed width fonts. A series of spaces following word might terminate farther right than the same series following another word. To get around this, I am using a "pre-tabbed" environment for my code segments which allows me to tab easily. %I would appreciate suggestions. SOMEBODY else must be doing this better. % //////////////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ % Dan Barrett, Department of Computer Science Johns Hopkins University % INTERNET: barrett@cs.jhu.edu % COMPUSERVE: >internet:barrett@cs.jhu.edu UUCP: barrett@jhunix.UUCP % \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\/////////////////////////////////////