.docname {Page counter}
.include {docs}

The **`.currentpage`** and **`.totalpages`** functions display, respectively, the current index (beginning from 1) of the page or slide where the function call appears and the total number of pages or slides. They do not accept any arguments.

These functions are supported in `paged` and `slides` documents. In other document types, the `-` placeholder is shown instead.

> Note: These functions return visual elements (nodes), *not* numbers. Therefore, you cannot perform operations like `.sum {.currentpage} {3}`.

## Fixed page counter

You can display a page counter on each page using [page margin content](page-margin-content.qd):

```markdown
.pagemargin {bottomcenter}
  .currentpage / .totalpages
```

## Formatting the page number

The **`.formatpagenumber {format}`** .docslink {quarkdown-stdlib/com.quarkdown.stdlib.module.Document/formatpagenumber.html} function sets a new page number format from the page where it appears. It only affects page numbers from that point onwards.

The format string accepts the same syntax as the one in [numbering](numbering.qd):

- `1` (default) for decimal (1, 2, 3, ...)
- `a` for lowercase latin alphabet (a, b, c, ...)
- `A` for uppercase latin alphabet (A, B, C, ...)
- `i` for lowercase roman numerals (i, ii, iii, ...)
- `I` for uppercase roman numerals (I, II, III, ...)

These changes are reflected in `.currentpage` and page numbers in the [table of contents](table-of-contents.qd).

.exampleoutput {![Page number format](page-counter/format.png)}
    .pagemargin {topcenter}
        .currentpage

    # First page

    .formatpagenumber {i}

    # Second page

    # Third page

## Resetting the page number

The **`.resetpagenumber {from?}`** .docslink {quarkdown-stdlib/com.quarkdown.stdlib.module.Document/resetpagenumber.html} function allows you to overwrite the current page number at any point in a `paged` or `slides` document.

These changes are reflected in `.currentpage` and page numbers in the [table of contents](table-of-contents.qd).

.exampleoutput {![Page number reset](page-counter/reset.png)}
    .pagemargin {topcenter}
        .currentpage

    # First page

    # Second page

    .resetpagenumber start:{20}

    # Third page