Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am looking for a package to have an environment for C++ source code, with options for syntax highlighting, automatic indentation, proper multipage behavior, etc.

I read something about the listings package but I guess there is already a good solution to my problem.

share|improve this question
add comment

1 Answer

up vote 12 down vote accepted

listings is the de facto standard for source code inclusion. It supports highlighting and its multipage behaviour should be alright.

Another option is minted, it is a bit harder to use but more powerful. You do get dependent on external software though (Pygments), it's not as cross-platform as just using a package.

Why do you want automatic indentation? I assume you are inputting existing files, they already should have good indentation according to a standard. It is a lot harder to accomplish this in a package, you'd have to write a full-blown parser for your language of choice and support all different indentation schemes, maybe Pygments can help you there, but I have never heard of this behaviour in TeX before.

share|improve this answer
    
OK, you make me realize that I don't need auto indentation ... I'll have a look at listings. –  Cedric H. Nov 1 '10 at 17:41
4  
If you really need auto indentation, you could always run the code through a C++ indenter before including it into your TeX. –  Mikael Vejdemo-Johansson Nov 1 '10 at 17:54
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.