[Tex/LaTex] Package to indent and syntax highlight C++ code

listingsmintedpackages

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.

Best Answer

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.