Terminally Incoherent

Utterly random, incoherent and disjointed rants and ramblings...

Monday, April 03, 2006

Code Segments in Latex

Whenever I copy and paste some code segments into my Latex documents, the verbatim environment eats my tabs. Apparently it is a feature, so I usually make my text editor convert tabs to n spaces before I import or copy the code into Kile. But that's annoying as hell!

The other day I found a simple and elegant solution. Use moreverb package. Somewhere at the beginning of the document do:


Then, instead of using normal verbatim environment do:

% code with tabs

Easy as pie! The only downside - Kile does not consider verbatimtab to be a verbatim like environment so it does not highlight the text inside a different color like it does for standard verbatim blocks. But that's a small price to pay for the added convenience.


Post a Comment

Links to this post:

Create a Link

<< Home