TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
up vote 13 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
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 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.