Refactoring and bug fix (for lower-level sections) for xref-pagenum-style template.