I would like to put the command \thispagestyle{empty}
after the beginning of a certain chapter and to put manually the page number at the same position, i.e., without invoking \thispagestyle{plain}
or similar commands. Note that I don't know what is the number of that page, so the page number should be determined automatically.
Is it possible?
For example in the following document I would like to manually put the page number 2 (of course 2 should be determined automatically) at the bottom of page 2.
\documentclass{report}
\begin{document}
\chapter{1}
\chapter{2}
\thispagestyle{empty}
\end{document}
Best Answer
Solution 0: Build in
As David said,
\thispagestyle{plain}
is the right command for this purpose (as long as you don’t say why it is impossible to use it in your case). Here’s the magic code ;-)The
plain
style is the default for chapter opening pages anyway …But to take a sledgehammer to crack a nut – or to shoot sparrows with cannons, as we say in Germany – here are two other ways:
Solution 1.1: Use
tikz
…… to place a node on an absolute position on the page. The page is access by a named node
current page.xx
, wherexx
can benorth
,north east
etc. for instance. Then a normal coordinate is added to shift the node to the correct position. The node is pinned to the position with its lower left (sour east
) corner and has no margin between the (invisible) border and the content. As said in my comment the current page number is stored in\thepage
. For more information please read the very good TikZ manual. To get the correct position the code must be compiled (at least) twice.Here’s the code:
In this version the number is placed 20mm from the right and 10mm from the bottom margin. Pleas figure out the correct values yourself (you may use
\onlypnum
on a page with a regular number an try to overlay both).Solution 1.2: Use
tikz
…… and the
tikzpagenodes
package. The latter package provides more nodes and makes the manual calculation/determination of the footer position obsolete. Here’s the code:Solution 2: New page style
To generate a new style I use
scrlayer-scrpage
, which is part of the KOMA-Script bundle. Another common package for this fast isfancyhdr
. I define a new styleonlypnum
(actually it’s a pair of styles) that only generates the page number in the center of the foot (=\cfoot
). The style can be used as usual with\(this)pagestyle
. Here’s the code:You may change
\cfoot
to suit you needs. See the KOMA-Script manual (English:scrguien.pdf
, German:scrguide
) for which positions are possible and further information.