0

I write a report in LaTeX for my study. In my report I have to include a PDF file. If I include the PDF file than I see the page number of the PDF file and the page number of my LaTeX PDF file. I want to remove the page number of the included PDF file but I don't know how. I use the following command:

\includepdf[pages=-,pagecommand={\chapter{Anhang}\pagestyle{plain}}]{Downloads/Interaktion_durch_Widgets/Interaktion_durch_Widgets-V2.pdf}

What do I have to change to get rid of the page numbers from included PDF file?

I have read the sites that you have sent me in the comments and I changed my command with use trim and clip. So my idea was to cut off the page number and use the command \includepdf[pages=1,pagecommand={\chapter{Anhang}}, trim=0cm 0cm 0cm 5cm, clip]{Interaktion_durch_Widgets-V2.pdf}

But the page number of the PDF file is still visible which u can see in the follow image

enter image description here

Werner
  • 603,163
  • 1
    The "inner" page numbers are an integral part of the PDF included as graphics. Treat it as regular graphics, hence you must either overlay or crop the unwanted contents. – ivankokan Nov 28 '20 at 03:29
  • Also related https://tex.stackexchange.com/questions/25806/how-can-i-crop-included-pdf-documents, https://tex.stackexchange.com/questions/325271/reduce-margins-of-a-pdf-with-includepdf, https://tex.stackexchange.com/questions/443540/trimming-the-blank-space-in-pdf-image-for-insertion-in-tex-file – Marijn Nov 28 '20 at 07:39
  • I used the command trim 0cm 0cm 0cm 10cm, clip and i still see the page number of my PDF file – Reazelruss Nov 28 '20 at 11:37
  • 1
    @Reazelruss We don't know how your included PDF looks and the positioning of "inner" page numbers. How do you expect us to trim and clip correctly? – ivankokan Nov 28 '20 at 12:58
  • @Reazelruss The forth parameter of trim means the top, the second the bottom. And your are missing an equal-sign after trim: Try this [trim=0mm 80mm 0mm 0mm, clip] – Andreas Matthias Nov 28 '20 at 19:59

1 Answers1

0

If you want to remove the footer (say) of the page you're including because it has the page number in it from the original document you have 2 options. Let's assume you have the following setup:

enter image description here

\documentclass{article}

\usepackage{lipsum}

\begin{document}

\section{A section} \lipsum[1]

% ...include PDF here

\end{document}

When you just include the PDF on the following page, this is what it looks like:

enter image description here

\documentclass{article}

\usepackage{lipsum} \usepackage{pdfpages}

\begin{document}

\section{A section} \lipsum[1]

\includepdf[ pages=1, pagecommand={} ]{lipsum50}% lipsum50.pdf is a document with \lipsum[1-50] in it

\end{document}

Here's a close-up of the page numbers on the second page:

enter image description here

The two options to remove the page number (1 in this case) include

  1. Use the trim and clip options provided by graphicx for trimming and clipping included graphics. From the pdfpages documentation:

Internally the command \includepdf makes use of the \includegraphics command from the graphicx (actually graphics) package. Hence it is possible to use all the options of \includegraphics, too. Options which are not interpreted by \includepdf are passed directly to \includegraphics.

Especially the trim and clip options of \includegraphics are quite useful, if only parts of a page should be inserted. (Maybe to cut off the header and footer of the inserted pages.) Just use the trim and clip options as if they were options of \includepdf. They will be passed to \includegraphics internally.

And here is how the trim option should be used (from the graphicx documentation):

trim

Similar to viewport, but here the four lengths specify the amount to remove or add to each side. trim= 1 2 3 4 "crops" the picture by 1bp at the left, 2bp at the bottom, 3bp on the right and 4bp at the top.

Note that bp here refers to big points, but you can specify other unit lengths. The the sake of brevity, let's trim 2cm off the top and bottom of the included page so it will remain vertically centred:

enter image description here

\documentclass{article}

\usepackage{lipsum} \usepackage{pdfpages}

\begin{document}

\section{A section} \lipsum[1]

\includepdf[ pages=1, pagecommand={}, trim=0 2cm 0 2cm, clip ]{lipsum50}

\end{document}

  1. Overwrite the page number with a white box so it's not visible.

Using the same example as above, we use eso-pic with some trial-and-error positioning of the white block in the ForeGround.

enter image description here

\documentclass{article}

\usepackage{lipsum} \usepackage{pdfpages,eso-pic,xcolor}

\begin{document}

\section{A section} \lipsum[1]

\clearpage \AddToShipoutPictureFG*{% Place content in the ForeGround of the current page only \AtPageLowerLeft{% Start placement at the lower-left of the page \makebox[\paperwidth]{% Move to the middle (horizontally) of the page \raisebox{3.5em}{% Raise box 5em from the bottom of the page \colorbox{orange}{% Use white instead; orange just for illustrative purpose \rule{2em}{0pt}% width \rule{0pt}{2em}% height }% }% }% }% }% \includepdf[ pages=1, pagecommand={} ]{lipsum50}

\end{document}

Werner
  • 603,163
  • Okay it works. How can I use it when I have more than one page ? – Reazelruss Nov 28 '20 at 22:56
  • @Reazelruss: If you go with the first option, there's no issue with including multiple pages since the trim and clip options would be the same for all pages. Are you using this option, or the second? – Werner Nov 29 '20 at 03:00
  • I only tried the second method because the first one didn't work for me. Now I tried the first method with your command trim=0 2cm 0 2cm, clip and it worked. The page number is gone. So I can use this method for an included PDF file that has many pages. Thank you for your help and your detailed answer. – Reazelruss Nov 29 '20 at 12:43
  • @Reazelruss: If my answer solved your problem, consider accepting it. See How do you accept an answer? – Werner Nov 30 '20 at 02:07