dmx dmx - 4 months ago 18
LaTeX Question

Adding pagination number to an included PDF page in LaTeX

I have a LaTeX document with a PDF containing a schema that has been included with

\includepdf[pages={1}, angle=-90]{yyyyyy.pdf}
. I would like this PDF to have right numbering like others pages. If I write a fixed page number on the PDF before inclusion this can not move because my document is still evolving.

Is there any way to add a page number (dynamically) in such case, or I must wait the end of my document to edit my page with the good page number and include into my document?

Answer

As werner said adding the option pagecommand={\thispagestyle{plain}} would make LaTeX number the page where you include the pdf. However this solution does not hide the original page number. Tilting the page also make the solution harder.

TikZ offer a rather hacky solution, it can overlay over your included pdf. See http://tex.stackexchange.com/questions/89588/positioning-relative-to-page-in-tikz to know more about it

Here is how to overlay a 2 on an included pdf, you might have to change the position a little to have it perfectly displayed :

\includepdf[ angle=-90,pagecommand={
\begin{tikzpicture}[remember picture, overlay,every node/.style={anchor=center}]
    \node [fill=white] at (page cs:-0.76,0) {2};
\end{tikzpicture}
}]{test.pdf}

Note that the coordinate system page is from the question I have lin ked.

With \pgfmathsetmacro{\page}{1} you can then change dynamically the page number you have placed.