From: Armin Roehrl Date: 2001-12-09T08:30:52+09:00 Subject: [ruby-talk:27983] Re: Displaying Ruby code in LaTeX On Sunday 09 December 2001 00:26, Sean Chittenden wrote: > > Has anyone written a document in LaTeX that includes examples of Ruby > > code? > > Yup. > > > I'm having all sorts of problems, because Ruby uses many characters > > that mean something to LaTeX. I tried to escape everything that was > > conflicting, but it's becoming a nightmare. > > Yeah, it's a tad annoying. What I'll typically do is write my chunk > of ruby, then use a query replace in emacs to change the $'s, &'s, > %'s, #'s, _'s, and {}'s to their respective escaped character. > > $ = \$ > & = \& > % = \% > # = \# > _ = \_ > { = \{ > } = \} > > > I even tried the verbatim environment, but that seems to screw up > > the indentation in a lot of cases. > > Ugh... not so nice. > > > So, can anyone give me an example of doing this, or suggest how I > > might attack it? > > Write a section of ruby, then escape a section of ruby. You could try > using the LyX program though which is pretty sweet and does most of > this for you. -sc Why don't you use \begin{verbatim} line1 line2 \end{verbatim} or \verb+Ruby.new+ for shorter bits. if a + would appear in your Ruby-code, you can use any other 2 start and stop chars for \verb. e.g.: \verb-2+2- -- Armin. ----------------------------------------------- Armin Roehrl, http://www.approximity.com