[texhax] Numbering/labeling verbatim code segments in a document

Lars Madsen daleif at imf.au.dk
Sun Feb 15 12:16:32 CET 2009


Don Gingrich wrote:
> I'm sorry to bother folks with what I suspect is a simple
> problem.
> 
> I've got a big document with a number of 68K assembler
> code segments embedded in the verbatim environment.
> 
> Since I am copying these code segments to proper source
> files and testing them, I would like to:
> 
> 1) Have them numbered/identified as <chapter>.<segment>
>    in the text
> 2) Have them captioned with a short description of what
>    they do so that I could have the equivalent of a 
>    table of figures that meaningfully lists the code 
>    snippets, where they are in the text and the description
> 
> This also means that, if I pass the original files to the 
> students, they will be able to easily load and experiment with 
> the code while reading the text.
> 
> Possibilities that I have considered:
> 
> some of the code environments - but none seem to do quite the right
> thing.
> 
> looked at the equation stuff too, but that doesn't look right either.
> 
> Sorry to impose, but I'm right up against a deadline.
> 
> Thanks,
> 
> -Don

why don't you have a look at the listings package, it is great for this 
sort of thing. THen you can keep your code in external files and just 
input the segments you want to explain.

/daleif


More information about the texhax mailing list