Tilted Forum Project Discussion Community

Go Back   Tilted Forum Project Discussion Community > Interests > Tilted Technology
New! Use your Facebook, Google, AIM & Yahoo accounts to securely log into this site, click logo to login  
Register Register Blogs Members List Mark Forums Read

Reply
 
LinkBack Thread Tools
Old 04-12-2006, 01:11 PM   #1 (permalink)
Beyond Belief
 
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   Reply With Quote
Old 04-12-2006, 07: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 07:29 PM..
phukraut is offline   Reply With Quote
Old 04-14-2006, 11:58 AM   #3 (permalink)
Beyond Belief
 
CSflim's Avatar
 
Location: Ireland
Excellent! Thanks very much, that worked great.
__________________
CSflim is offline   Reply With Quote
Old 04-15-2006, 12:45 PM   #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   Reply With Quote
Reply

Bookmarks

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 04:45 PM.

Contact Us - Tilted Forum Project - Archive - Top

Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
All text © 2002-2009 Tilted Forum Project
"Insignia" vBulletin 3.5 - b6gm6n - x7x7x7.com