Tilted Forum Project Discussion Community

Tilted Forum Project Discussion Community (https://thetfp.com/tfp/)
-   Tilted Technology (https://thetfp.com/tfp/tilted-technology/)
-   -   LaTeX help: code listings. (https://thetfp.com/tfp/tilted-technology/103345-latex-help-code-listings.html)

CSflim 04-12-2006 12:11 PM

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!

http://i50.photobucket.com/albums/f3...TeXProblem.gif

Can someone help me out here?

phukraut 04-12-2006 06:22 PM

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.

CSflim 04-14-2006 10:58 AM

Excellent! Thanks very much, that worked great.

phukraut 04-15-2006 11:45 AM

You're welcome. I learned something new too: I didn't know about the "listings" package until I looked it up. Cheers.


All times are GMT -8. The time now is 02:26 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, 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