# How to add common pagenumber without decreasing page size?

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{}

\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}}


\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

• Don't use \thispagestyle{plain}; you need \thispagestyle{fancy} for it to match your fancy pages style. – Werner Nov 8 '16 at 7:12
• The default under the fancy page style is to have a header rule. To remove this, set \renewcommand{\headrulewidth}{0pt}. – Werner Nov 8 '16 at 7:18
• ...also, I don't understand your "keep the page size request". Do you want to keep the page size of the original article, or the one you want to include? – Werner Nov 8 '16 at 7:19
• Sure, try: \let\oldincludepdf\includepdf \renewcommand{\includepdf}[2][]{\oldincludepdf[pagecommand=\thispagestyle{fancy},#1]{#2}} – Werner Nov 8 '16 at 7:22
• Sorry, use \usepackage{letltxmacro} \LetLtxMacro\oldincludepdf\includepdf \renewcommand{\includepdf}[2][]{\oldincludepdf[pagecommand={\thispagestyle{fancy}},#1]{#2}}. – Werner Nov 8 '16 at 7:33

Add each page with the pagecommand={\thispagestyle{fancy}} option, or "automate" the process via
\usepackage{letltxmacro}