Document Class (or Alternative Solution) for Documenting Programming Code

Different from writing a report or thesis involving code, I have the goal of producing a transcription of a C++ solution involving many projects with many .h and .cpp files. Furthermore, this document I am trying to produce will have a focus on the mathematical equations.

So far, I am giving each project a chapter, each file a section and each function a subsection, using \begin{chapter}{Project}, etc.

So my questions are:

1. Is there a document class appropriate for this undertaking?
2. If not, has anyone done this before, and what is the best method you've found?
3. If no one has done this before, what ideas do you all have?
4. At the furthest extreme, would I have to create a new document class?

As a side question, I am using TeXmaker. Any idea how to get \begin{section}{File.cpp} to appear in the structure pane?

• Have a look at the listings and minted packages. They are both exceptionally good for code highlighting. My preference is to use listings and, in particular, the \lstinputlisting command to directly include source from an external file. – Andrew Nov 14 at 23:54
• See if your university has a specific document class or template for LaTeX. Otherwise, start with book,cls and get the university requirements. – John Kormylo Nov 15 at 5:34
• The ltxdoc documentclass is set up for documenting style packages, and may (or not) be adaptable to your need. The numberedblock provides a way to typeset code blocks in the manner of numbered equations. – Steven B. Segletes Nov 15 at 10:42