3

I'm using the pdfpages package to insert pages from existing pdfs into my tex file. I want to override the page numbering on the pdf pages I'm inserting.

Below is an image of what is happening in terms of page numbering when I use

\includepdf[pages=-,pagecommand={}]{filename}

The original page numbering is "0", and the page number being added by pdfpages is "3". I'd like for the "3" to be the only number that shows up.



Edit: Thanks for all the help!

Below is my code.

\documentclass{article}
\usepackage{pdfpages}

\newcommand{\ip}[1]{\includepdf[pages=-,pagecommand={},clip, 
  trim=5mm 37mm 5mm 20mm]{#1.pdf}}

\begin{document}

\ip{d}
\ip{g}
\ip{h}

\end{document}

Example PDF. Also, is there a way to replace the cropped out part with dummy space, shift the document upward, or lower the page numbering? Otherwise, the page numbering is appearing over the text.

  • 2
    You probably just need to trim off the original page numbers. You can pass includepdf the clip and trim options that apply to the \includegraphics command. – Michael Palmer Sep 1 '17 at 2:05
  • Welcome! Cropping seems the way to go, as suggested already. If you need further help, please provide code for a minimal document we can compile to produce the output you want help with. A picture of your output alone isn't much help. A complete but minimal example is much more useful than mere fragments of code. – cfr Sep 1 '17 at 2:23
2

As indicated in the comments, the solution here is to trim the existing page numbers. The original page size is restored using the pdfpages key templatesize. Checking the properties of the example pdf file tells us that its size is 215.9mm x 279.4mm.

We can restore page numbers using \pagecommand={\pagestyle{plain}}. However, the default page number position overwrites the text at the bottom of page 2. Therefore, the new page numbers are produced using a customized footer and the fancyhdr package:

\newcommand{\myfooter}{%
    \fancyfoot{}
    \fancyfoot[C]{\vspace{1cm}\thepage} }

The footer is invoked using \pagestyle{fancy}.

This is the MWE:

\documentclass[letter]{article}
\usepackage{pdfpages}
\usepackage{fancyhdr} % Needed for customized footer

\renewcommand{\headrulewidth}{0.0pt} % Eliminate rule in header
\newcommand{\myfooter}{              % Place the page number 1cm below default position
    \fancyfoot{}
    \fancyfoot[C]{\vspace{1cm}\thepage}
}

\includepdfset{                      % Setup keys for calls of \includepdf
    pages=-,
    templatesize={215.9mm}{279.4mm}, % Because the page gets trimmed reset the page size
    nup=1x1,
    scale=1,
    clip, 
    trim=5mm 36.5mm 5mm 20mm,        % Trim off the exisitng page numbers
    fitpaper=true,
    pagecommand={\myfooter}          % Apply the customized page numbering
}

\pagestyle{fancy}

\begin{document}

\includepdf{example} % Example pdf supplied by OP

\end{document}
  • It seems that only options specific to pdfpages can be made global by \includepdfset. Since trim and clip are options of the graphicx package, these need to be included in each call, e.g. \includepdf[trim = {5mm 36.5mm 5mm 20mm}, clip = true]{example}. Not sure if that's new, but this made the example work for me. – Heather Turner Nov 15 '17 at 14:40

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.