Adding page numbers in QGIS Layouts can be done with the [% @layout_page %]
expression. In Reports, however, the [% @layout_page %]
expression always remains "1"
How do we insert the page number in a Report?
We would need a @report_page
variable, which at the moment is not available.
However there is a:
pagenum
.Field
in the left pane of the Report editor).pagenum
with sequential numbers, increasing it when the controlling field changes.[% "pagenum" %]
.You can go one step further, and insert an expression to compute the total number of pages:
Page number: [% "pagenum" %] of [% count_distinct( "pagenum" ) + 1 %]
The + 1
here is for taking into account the header page, if any.