How to render Android listings with syntax highlighting?

I need to include the source code of a bigger Android project in the documentation written with LaTeX. Do you recommend any particular package that is capable of highlighting Java code and which also addresses the specific class types added by the Android framework?
My Android project has been developed with Eclipse.

Optional:

• It would be also convenient if there is any package that reads the project structure with package names and folders and generates some kind of table of contents from it.
• What is your opinion on the minted package that uses pygments as a syntax highlighter?
-

1 Answer

Seems like a job for either the listings or the minted packages; both are customizable and offer Java as one of the predefined languages.

Using listings you can define your own set of rules for syntax highlighting for Android (see Sections 3.2 and 4.18 Language definitions of the package documentation)); Android is not one of the predefined languages in minted either, so you will also have to define a new language.

Additionally, with each one of the packages you can easily produce a list of your listings using \lstlistoflistings (with listings) or \listoflistings (with minted), and you can input your code from external files using \lstinputlisting (with listings) or \inputminted (with minted).

Since minted uses Pygments, it provides far superior syntax highlighting compared to listings; on the other hand, listings offers automatic breaking of long lines and, as far as I know, this feature is not offered by minted.

-
Do you know of a LaTeX listings definition for Android similar to this C# list that has been composed by the community or someone else? –  JJD Sep 2 '12 at 23:24
@JJD no; I don't know of any existing definition for Android; perhaps, if you provide one, you could send it to the listings package maintainer so that it could be included in future releases. –  Gonzalo Medina Sep 2 '12 at 23:29
I did not know that someone will integrate such options. I definitely will submit it then. Though, I am pretty sure that somebody else already prepared a list somewhere - I just cannot find it ... –  JJD Sep 3 '12 at 0:10
@JJD I've updated my answer with some information on minted (I hadn't seen your edit to the original question). –  Gonzalo Medina Sep 3 '12 at 17:27
Very nice edit of yours. I appreciate the details about the commands and supported features of the individual packages. Seems like a hard decision, nevertheless. –  JJD Sep 3 '12 at 17:59