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


% https://tex.stackexchange.com/q/56316/13173

\renewcommand{\headrulewidth}{0pt} % Werner, remove top margin border


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

enter image description here enter image description here

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

enter image description here

TeXLive 2016
OS: Debian 8.5

  • 1
    Don't use \thispagestyle{plain}; you need \thispagestyle{fancy} for it to match your fancy pages style.
    – Werner
    Nov 8, 2016 at 7:12
  • 1
    The default under the fancy page style is to have a header rule. To remove this, set \renewcommand{\headrulewidth}{0pt}.
    – Werner
    Nov 8, 2016 at 7:18
  • 1
    ...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, 2016 at 7:19
  • 1
    Sure, try: \let\oldincludepdf\includepdf \renewcommand{\includepdf}[2][]{\oldincludepdf[pagecommand=\thispagestyle{fancy},#1]{#2}}
    – Werner
    Nov 8, 2016 at 7:22
  • 1
    Sorry, use \usepackage{letltxmacro} \LetLtxMacro\oldincludepdf\includepdf \renewcommand{\includepdf}[2][]{\oldincludepdf[pagecommand={\thispagestyle{fancy}},#1]{#2}}.
    – Werner
    Nov 8, 2016 at 7:33

1 Answer 1


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


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.