Tilted Forum Project Discussion Community  

Go Back   Tilted Forum Project Discussion Community > Interests > Tilted Technology


 
 
LinkBack Thread Tools
Old 04-12-2006, 12:11 PM   #1 (permalink)
Sky Piercer
 
CSflim's Avatar
 
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?
__________________
CSflim is offline  
Old 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}
This package is also interesting because you can define what language you are coding in and it will do selective bolding, etc. In classic LaTeX style, it's a VERY customizable package.

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..
phukraut is offline  
Old 04-14-2006, 10:58 AM   #3 (permalink)
Sky Piercer
 
CSflim's Avatar
 
Location: Ireland
Excellent! Thanks very much, that worked great.
__________________
CSflim is offline  
Old 04-15-2006, 11:45 AM   #4 (permalink)
Addict
 
You're welcome. I learned something new too: I didn't know about the "listings" package until I looked it up. Cheers.
phukraut is offline  
 

Tags
code, latex, listings

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -8. The time now is 10:52 PM.

Tilted Forum Project

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Search Engine Optimization by vBSEO 3.6.0 PL2
© 2002-2012 Tilted Forum Project

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73