1

I'd like to define in Lualatex a way to add a text after each page. For example, add a code that display a big stamp in the middle of the page on top of the text (adbegshi does something similar, but it adds the text at the beginning of the page) that displays the current page number. For now, the following code add this only at the end of the last page.

NB : I do NOT want to use an external file and use pdfpages to include the pages, I'd like to have a solution in one single file.

MWE:

\documentclass{article}
\usepackage{lipsum}
\usepackage{tikz}
\begin{document}%
\lipsum[1-20]
\begin{tikzpicture}[remember picture,overlay]
  \node[text=red] at (current page.center) {\Huge \textbf{\thepage}};
\end{tikzpicture}
\end{document}

-- EDIT -- The solution given solve indeed my problem, but I'm curious to know if it's possible to do that in "pure" lualatex, using hooks or something like that. Thanks !

3

atbegshi offers the command \AtBeginShipoutAddToBoxForeground but normally I do find eso-pic easier to use for this sort of things:

\documentclass{article}
\usepackage{lipsum}
\usepackage{tikz}
\usepackage{eso-pic}
\begin{document}%
\AddToShipoutPictureFG{%
\begin{tikzpicture}[remember picture,overlay]
  \node[text=red] at (current page.center) {\Huge \textbf{\thepage}};
\end{tikzpicture}}
\lipsum[1-20]
\end{document}

enter image description here

  • there is \AtPageCenter macro with eso-pic which could be used here avoiding loading of tikz. (but I don't know exactly how tikz behaves when putting text at some location, for example here, is the 1 really centered in the page?) – user4686 Nov 11 '17 at 15:38
  • Oh, I missed this great feature, thanks! And for educational purpose, does someone know if it's possible to do that in pure lualatex? – tobiasBora Nov 11 '17 at 16:12
  • What do you mean by "pure" lualatex? The code works fine there. – Ulrike Fischer Nov 11 '17 at 16:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.