04-12-2006, 12:11 PM | #1 (permalink) |
Sky Piercer
Location: Ireland
|
LaTeX help: code listings.
Hi!
I have just a few days ago started migrated from Microsoft Word to using LaTeX. So far I am quite impressed - but I am completely new to it, so I am still trying to find my way around it. One thing I want to do is include bits of source code listings into my document. Of course there are problems with that - I don't want to have to go through my entire source code and escape out all of the LaTeX 'reserved' symbols. So I have used the 'verbatim' environment, which works quite well, but there is one problem - it doesn't wrap lines! Can someone help me out here?
__________________
|
04-12-2006, 06:22 PM | #2 (permalink) |
Addict
|
Use the "listings" package instead. This gives the option of breaking long lines with an adjustable indent. "breaklines=true" sets the line break, and you can set specific symbols to put before and after breaks to indicate them using "prebreak" and "postbreak". This example comes out of "The LaTeX Companion, 2nd Ed." (Mittelbach and Goossens), page 173:
Code:
\usepackage{color,listings} \lset{breaklines=true,breakindent=0pt, prebreak=\mbox{\tiny$\searrow$}, postbreak=\mbox{{\color{blue}\tiny$\rightarrow$}}} \begin{lstlisting} SOURCE CODE GOES HERE \end{lstlistings} Oh, and I highly recommend that book I quoted. It's rather comprehensive. "A Guide To LaTeX" by Kopka and Daly is not bad either, but much more basic. Last edited by phukraut; 04-12-2006 at 06:29 PM.. |
Tags |
code, latex, listings |
|
|