You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The r2rtf package supports several control words for page numbering in tables. These control words can be used in titles, headers, footnotes, and other text elements.
244
+
245
+
### Available Control Words
246
+
247
+
| Control Word | Description | Use Case |
248
+
|--------------|-------------|----------|
249
+
|`\pagenumber`| Dynamic RTF page field (document-level) | When you need the actual document page number |
250
+
|`\pagenumber_hardcoding`| Hardcoded table-specific page number | For multi-page tables with table-relative page numbering (e.g., "Page 1 of 3") |
251
+
|`\totalpage`| Total number of pages in the table | Works with `\pagenumber_hardcoding` to show "X of Y" format |
252
+
|`\pagefield`| RTF NUMPAGES field code | For total document pages |
253
+
254
+
### Example 1: Using `\pagenumber` (Document-Level Page Number)
255
+
256
+
This example uses `\pagenumber` which shows the document-level page number. When multiple tables are combined, it shows the absolute page position in the document.
257
+
258
+
```{r}
259
+
tbl1_file <- tempfile(fileext = ".rtf")
260
+
tbl2_file <- tempfile(fileext = ".rtf")
261
+
262
+
iris[1:30, ] |>
263
+
rtf_title("Table 1: Iris Data (Page \\pagenumber)") |>
### Example 2: Using `\pagenumber_hardcoding` (Table-Specific Page Number)
287
+
288
+
This example uses `\pagenumber_hardcoding` which shows the table-specific page number. When multiple tables are combined, each table maintains its own independent page numbering (1/N, 2/N, etc.). Note that Table 1 spans multiple pages to demonstrate how the page counter works within a single table.
289
+
290
+
```{r}
291
+
tbl3_file <- tempfile(fileext = ".rtf")
292
+
tbl4_file <- tempfile(fileext = ".rtf")
293
+
294
+
# Create a multi-page table to demonstrate page numbering within a single table
295
+
iris[1:100, ] |>
296
+
rtf_title("Table 1: Iris Data (\\pagenumber_hardcoding/\\totalpage)") |>
- Use when: You need table-relative page numbering where each table has its own counter
330
+
- Behavior: Each table's pages are numbered independently starting from 1. This is especially useful for multi-page tables that need internal page tracking.
0 commit comments