Why Pagination Needs a Plan
A diagnostic figure that works for six subjects can become difficult to use when it contains plots for hundreds. Pagination is not just a way to split a long figure into files. It determines whether a reviewer can locate a subject, compare panels across pages, and trust that every intended plot is present exactly once. A page break that changes unpredictably when data are added or rows arrive in a different order can make a report hard to review and hard to reproduce.
A reliable pagination plan specifies the eligible plots, their ordering, the number of panels per page, and the information displayed in page and panel labels. These decisions should be made before rendering. The plot content itself may be an individual fit panel or another diagnostic panel; pagination arranges those plots and does not change how their diagnostic quantities are calculated or interpreted.
Define Eligibility, Order, and Layout
Begin by defining the set of plot units to paginate. State the identifier that makes each unit unique, such as subject ID or the combination of study and subject ID. Decide how to handle units for which a plot cannot be produced. For example, if a subject has no usable observations for a requested panel, the reporting rule might omit that panel or include a labeled placeholder. The choice should be explicit and applied consistently; otherwise the expected number of plots is ambiguous. The earlier material on handling missing diagnostic quantities in plots addresses missing values within plots, while this tutorial focuses on arranging the resulting plot units.
Next, define a canonical order. Sorting by a stable identifier is usually preferable to using the order in which records happen to appear in an input file. For text identifiers, specify whether ordering is lexical or numeric. For example, lexical ordering can put “ID10” before “ID2”; if numeric order is intended, extract or otherwise define the numeric component. If plots are grouped by study, occasion, or subgroup, specify the order of those groups and the order of units within each group.
Choose a fixed page capacity and panel arrangement. A page might have two columns and three rows, giving \(C=6\) panels. The final page can contain fewer than six plots, but the other pages should use the same panel dimensions and positions. Decide whether unused positions on the final page remain blank or are removed. Keeping the same grid is often easier to compare and produces consistent output dimensions; removing empty positions can make the last page more compact but changes the page geometry.
The rule assumes every eligible unit contributes exactly one plot and each page has the same capacity. If some units contribute multiple panels, define the plot unit more precisely or calculate pagination from the actual panel list. Never calculate page count from a subject count if the rendered panel count differs from that count.
From an Ordered List to Pages
The assignment formula follows from counting positions in blocks of \(C\). Positions 1 through \(C\) belong to page 1; positions \(C+1\) through \(2C\) belong to page 2; and so on. Subtracting one makes the first position zero, so integer division by \(C\) gives the page index starting at zero. Adding one converts it back to a one-based page number. The remainder after division identifies the within-page position, and adding one makes that position one-based.
This assignment is complete and non-overlapping: every position \(k\) has one quotient and one remainder on division by \(C\), so it maps to exactly one page and one slot. Conversely, the ordered positions assigned to successive pages are consecutive blocks, so no position is skipped. This guarantee depends on assigning positions after establishing the eligible list and its order, rather than relying on incidental row order.
Worked Example: Paginating Subject Panels on a Fixed Grid
Suppose a hypothetical diagnostic report has 37 eligible subjects, ordered numerically by subject ID. Each page has a three-row, two-column grid, so the capacity is \(C=3\times2=6\). Calculate the number of pages and locate the panels for subjects in positions 13 and 37.
The page count is \(\lceil N/C\rceil=\lceil37/6\rceil=\lceil6.1667\rceil=7\). The first six pages can hold \(6\times6=36\) plots, leaving \(37-36=1\) plot on page 7. Each page retains the same three-by-two dimensions; five slots on the final page are unused.
For position \(k=13\), page \(=\lfloor(13-1)/6\rfloor+1=\lfloor2\rfloor+1=3\). The slot is \(((13-1)\bmod6)+1=0+1=1\). Thus the thirteenth subject in the defined order appears in the first slot of page 3.
For position \(k=37\), page \(=\lfloor36/6\rfloor+1=6+1=7\). The slot is \((36\bmod6)+1=0+1=1\). The last subject appears in the first slot of page 7. This check agrees with the count of one plot on the final page.
Labels That Make Pages Findable
A page number alone identifies position in a document, not the plots on that page. A useful page label includes the report or analysis identifier, the page number and total page count, and a short description of the contents. For subject panels, a title such as “Subjects 101–106” is informative only if the displayed subjects are actually consecutive in the stated order. If IDs are nonconsecutive, a range can mislead; use a defined subgroup label or an accurate first-to-last description accompanied by the ordering rule.
Panel titles should display the plot-unit identifier clearly. If subgroups are paginated separately, include the subgroup name on each page, not only on the first page of the report. When a subgroup spans several pages, label both the subgroup and page position, such as “Dose group B — page 2 of 3.” Include enough context that a page remains interpretable if it is viewed or printed separately.
Page numbering should be generated from the final page assignment, not typed manually. Keep identifiers in labels consistent with the keys used to create the plots. A mismatch between the panel title and the plotted data can be more serious than an unattractive layout because it assigns evidence to the wrong subject.
Worked Example: Paginating Subgroups Independently
In a hypothetical study, eligible subjects are assigned to three dose subgroups: Low has 11 subjects, Medium has 6, and High has 5. Each subgroup receives its own pages with a two-by-two grid, so \(C=4\). The specified subgroup order is Low, Medium, High, and subjects are sorted numerically within each subgroup.
For Low, the page count is \(\lceil11/4\rceil=3\): pages 1 and 2 contain four plots each, and page 3 contains \(11-8=3\). For Medium, \(\lceil6/4\rceil=2\), with four plots followed by two. For High, \(\lceil5/4\rceil=2\), with four plots followed by one. There are \(3+2+2=7\) pages in total.
The page labels should identify both subgroup and local page position: “Low — page 1 of 3,” “Medium — page 2 of 2,” and so forth. If the report also uses a single continuous page number, that number is separate from the subgroup-local position. Making both explicit prevents “page 2” from being mistaken for the second page of the whole report when it means the second page within a subgroup.
The final pages have three, two, and one plots, respectively. Their unused grid positions remain blank under the chosen fixed-grid rule. A check of the total confirms that all \(11+6+5=22\) eligible subjects are assigned, and the seven pages provide \(7\times4=28\) slots, of which \(28-22=6\) are unused.
Check the Result Before Rendering
Pagination errors are often data-management errors made visible by the figure. Before rendering, compare the ordered list of eligible plot keys with the keys assigned to pages. They should have the same length and the same membership. Each key should occur once. After rendering, check that the number of panels matches the planned count on every page, that labels match the assigned keys, and that the final page has the expected number of occupied slots.
Apply the stated inclusion rule, resolve duplicate keys, and record any units intentionally omitted or represented by placeholders.
Apply the documented group and identifier ordering, then assign page and slot from the ordered positions and chosen capacity.
Check that every eligible key appears once, no ineligible key appears, and the page and slot counts agree with the planned capacity.
Confirm page labels, panel identifiers, grid dimensions, and the intended treatment of empty slots, especially on the final page.
Typical warning signs include a page count that changes when the input rows are shuffled, repeated or absent IDs, inconsistent panel sizes, a page label that does not match its contents, or a final page with an unexpected number of plots. Reordering the same input records is a useful reproducibility check: with the same eligible keys and sorting rule, the page assignments should not change.
Worked Example: Detecting a Pagination Count Error
A hypothetical report has 18 eligible subject plots and a capacity of \(C=5\). A draft report contains four pages, each displaying five plots. Determine whether this output is consistent with the plan and identify a likely issue.
The required page count is \(\lceil18/5\rceil=\lceil3.6\rceil=4\), so four pages is plausible. However, the draft displays \(4\times5=20\) plots. The plan has only 18 eligible plot units, so two displayed panels must be duplicates, unintended plots, or placeholders being counted as ordinary subject plots. If the intended final page has only the remaining eligible panels, its occupied count is \(18-3\times5=3\), not five.
A complete check compares the panel keys with the eligible key list, rather than relying only on the page count. If two keys are duplicated and two eligible keys are absent, the page count can still be correct while the content is wrong. The correction is to verify key membership and uniqueness, then regenerate pages and labels from the validated assignment.
Alternatives, Trade-Offs, and Common Mistakes
| Approach | Useful when | Main trade-off |
|---|---|---|
| Fixed multi-panel grid | Many similarly structured plots need compact review and consistent page geometry. | Panels can become too small, and the final page may have blank slots. |
| One plot per page | Each plot needs substantial space or detailed annotation. | Produces a long document and makes rapid comparison across subjects less convenient. |
| Separate pages by subgroup | Subgroups are a primary review unit and each page needs clear group context. | Small groups can leave sparse pages; subgroup-specific page numbering must be clear. |
A common mistake is to paginate in input-file order and assume that order is stable. The reasoning is that the same data are present, so the same subjects should remain together. That conclusion does not follow: input rows may be sorted differently during export, merging, or filtering. The correction is to sort by an explicit, unique key before assigning page and slot, and to document tie-breaking rules for composite keys.
Another mistake is to choose the largest possible grid simply to reduce the page count. More panels per page can shrink plots until patterns, axes, or identifiers are difficult to read. Conversely, using one plot per page can make a large report unwieldy. The appropriate capacity depends on the intended page dimensions and the amount of information each panel must display. This is a layout decision; it should be checked at the final rendered size.
Pagination also has limits. A consistent grid cannot resolve sparse or uninformative data within a plot, and a complete set of pages does not establish that the plots are scientifically adequate. Large reports may still require an index or navigation aid, but page organization should remain understandable without relying on hidden software state. Changes to eligibility rules, ordering, or capacity can change page assignments; record those rules with the report so that later reruns can be compared fairly.
Check Your Understanding
Answer each question, then compare with the solutions below.
- A report has 29 eligible subject plots and a capacity of 8. How many pages are required, and how many plots are on the final page?
- With a capacity of 6, what page and slot contain the plot in ordered position 20?
- Why can a correct page count fail to reveal duplicated or missing subject panels?
- A report paginates subgroups independently. What information should distinguish subgroup-local page numbers from continuous report page numbers?
Solutions. (1) \(\lceil29/8\rceil=4\) pages; the first three hold 24 plots, leaving \(29-24=5\) on the final page. (2) Page \(=\lfloor(20-1)/6\rfloor+1=\lfloor19/6\rfloor+1=4\); slot \(=(19\bmod6)+1=2\). (3) The page count depends on the number of displayed panels, not whether their keys are correct; duplicates can replace omitted keys without changing the count. Compare the rendered keys with the eligible key list and check uniqueness. (4) Label subgroup and local page position, for example “Group A — page 2 of 3,” and distinguish that from the continuous page number in the full report.