if you want to generate beautifully paginated pdf / printable pages from your html i cannot recommend enough https://www.pagedjs.org/. it supports page numbers, tos, footnotes, dynamic references (see table on page x
link ) and a lot of other very cool stuff