I would like to typeset some source code (~70k lines).
The language is Objective-C so it is organized into classes. I would like a table of contents, and page numbers. I would also like each class to start at the top of a page.
It would be good to be able to add inline comments to some parts of this code. It would also be nice to add some cross-reference links between certain parts of the document. (Both of these manually).
Which is the best package to produce something like this (you can also tell me not to use TeX)?
Best Answer
Here are three powerful packages you can use to typeset Objective-C source code:
listings
,minted
,verbments
. All three packagesSo, which one should you choose? It depends on your requirements. A couple of things to know before you make your decision:
minted
andverbments
packages are very similar. See minted vs. texments vs. verbments for a more detailed comparison. They're both based onpygments
and require a call to some Python code, which means you need to enable-shell-escape
when compiling yourtex
file. In comparison,listings
performs all the syntax highlighting directly in TeX.listings
package has limited lexing and syntax-highlighting capabilities compared to the other two packages.minted
(orverbments
) listings often look prettier, in my opinion.listings
allows for some customisation of the syntax highlighting in the.tex
file, whereas the others require some extra Python fiddling outside the.tex
file.listings
has an automatic line-breaking feature, which the others don't offer. The bottom last screenshot below shows what happens whenminted
is used to typeset a listing that is too wide to fit on the page. Of course, you may choose to reduce the font size to avoid that kind of problem.Here is an example using
listings
. See the documentation for more details.minted
example