Skip to contents

Pagination

Pagination Algorithm

Pagination is performed independently in the vertical and horizontal directions based solely on a pagination data.frame, which includes the following information for each row/column:

  • number of lines/characters rendering the row will take after word-wrapping (self_extent)

  • the indices (reprint_inds) and number of lines (par_extent) of the rows which act as context for the row

  • the row's number of siblings and position within its siblings

Given lpp (cpp) already adjusted for rendered elements which are not rows/columns and a dataframe of pagination information, pagination is performed via the following algorithm, and with a start = 1:

Core Pagination Algorithm:

  1. Initial guess for pagination point is start + lpp (start + cpp)

  2. While the guess is not a valid pagination position, and guess > start, decrement guess and repeat

  • an error is thrown if all possible pagination positions between start and start + lpp (start + cpp) would ever be < start after decrementing

  1. Retain pagination index

  2. if pagination point was less than NROW(tt) (ncol(tt)), set start to pos + 1, and repeat steps (1) - (4).

Validating pagination position:

Given an (already adjusted) lpp or cpp value, a pagination is invalid if:

  • The rows/columns on the page would take more than (adjusted) lpp lines/cpp characters to render including

    • word-wrapping

    • (vertical only) context repetition

  • (vertical only) footnote messages and or section divider lines take up too many lines after rendering rows

  • (vertical only) row is a label or content (row-group summary) row

  • (vertical only) row at the pagination point has siblings, and it has less than min_siblings preceding or following siblings

  • pagination would occur within a sub-table listed in nosplitin