OK, here's this patch one more time, updated to current trunk. Comments welcome. I'll commit some time Tuesday unless there are objections.
By the way, does anyone know if the "by chapter" and "by section" modules should be included, excluded, or whatever from SIAM? I assume there is some fixed way they do things?
Richard