I can include pdf documents as they are in the common pdf document, but I cannot do it with common page numbering in the top right corner. The following fancyhdr
does not have any effect on have page numbering on the top of pdf documents. It would be great if the page numbering would be on top of pdf documents because they are just articles where plenty of space there. Code proposed based on the thread Base document page numbers with pdfpages about base document
\documentclass{article}\usepackage{pdfpages}% https://tex.stackexchange.com/q/56316/13173\usepackage{fancyhdr}\pagestyle{fancy}\fancyhf{}\fancyhead[R]{\thepage}\renewcommand{\headrulewidth}{0pt} % Werner, remove top margin border\begin{document}\includepdf[pagecommand=\thispagestyle{plain}]{sforzo.pdf}\includepdf[pagecommand=\thispagestyle{plain}]{testData.pdf}\includepdf[pagecommand=\thispagestyle{plain}]{sforzo.pdf}\end{document}
Fig. 1 Output with pagestyle{plain}
where you see that the approach decreases the size of the page, Fig. 2 Output with pagestyle{fancy}
and renewcommand
The fancy
pagestyle looks better, but I would still like to maintain the page size. The following Werner's proposal stays in loop and never ends, so I cannot get any output with it
\let\oldincludepdf\includepdf \renewcommand{\includepdf}[2][]{\oldincludepdf[pagecommand=\thispagestyle{fancy},#1]{#2}}
Werner's correct answer
\usepackage{letltxmacro} \LetLtxMacro\oldincludepdf\includepdf \renewcommand{\includepdf}[2][]{\oldincludepdf[pagecommand={\thispagestyle{fancy}},#1]{#2}}
Output without decreasing the page size
TeXLive 2016
OS: Debian 8.5