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.


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.

| 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
  • 5
    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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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