## LaTeX forum ⇒ Page Layout ⇒ Proper way to include a pdf as an appendix Topic is solved

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
javascripter
Posts: 3
Joined: Mon Feb 10, 2020 7:04 pm

### Proper way to include a pdf as an appendix

so, I am including pdfs as an appendix, so far I have been using pdfpages to just include the whole pdf. However, this caused a problem if I use the \chapter{appendix name} method, as the header causes there to be any empty page with no text. I solved this with :

\addcontentsline{toc}{chapter}{\protect Appendix \arabic{appen} \hspace{2mm} Power Node User Manual}
\stepcounter{appen}

which works fine, except the page numbering and appendix numbering is no longer correct. I've gotten some idea of how to do it manually, but the problem i'm stuck on now is that I can't get the page number to be overlayed over the pdf, instead it is always underneath and thus not visible. tried using both fancyhf and eso-pic, at least to the point that they work on an appendix that doesn't have a pdf included.

So how do I overlay the appendix/page numbering over the pdf, or does someone else have a reccomendation for a better way to include an appendix from a pdf

Ijon Tichy
Posts: 188
Joined: Mon Dec 24, 2018 10:12 am
Usually appen is not the counter for the appendices. So all I write here is very speculative.

Why don't you use the addtotoc option of \includepdf? And if you want another page style for the included PDF pages, you may try option pagecommand, e.g., pagecommand={\thispagestyle{plain}}.

If this does not help, please show a minimal working example. For the MWE, you can use one of the multi-page PDFs of package mwe instead of your original appendix PDF-file. If not, we would need a download link to be able to reproduce the problem.

javascripter
Posts: 3
Joined: Mon Feb 10, 2020 7:04 pm
Sorry, I should have explained that appen is a counter I created myself to keep track of appendix numbering

I was unaware I could add things to table of contents that way, but it would also work, I would just have to figure out the formatting to get it in the format that I want

but here is minimum working example showing my problem:

\documentclass{article}\usepackage{pdfpages}\usepackage{mwe}\usepackage{eso-pic}\usepackage{lastpage}\begin{document}\AddToShipoutPictureBG*{% \AtPageUpperLeft{% \hspace{\paperwidth}% \raisebox{-\baselineskip}{% \makebox[0pt][r]{Appendix x \hspace{15mm}}}}}%\AddToShipoutPictureBG*{% \AtPageUpperLeft{% \hspace{\paperwidth}% \raisebox{-\baselineskip-\baselineskip}{% \makebox[0pt][r]{\thepage \hspace{1mm} (\pageref{LastPage}) \hspace{20mm}}}}}%\includepdf[pages=-]{example-image-10x16.pdf}\includepdf[pages=-]{example-image-a.pdf}\end{document}

I have used eso-pic, but don't really care how it is achieved. In the result the pdf is over the page numbering, which is the problem I am having. In my use case that part of the pdf is white, and pdf has no numbering by default, so I would like to superimpose correct numbering on it.
A secondary problem is that the second page doesn't have the numbering as well.

example doesn't have toc as that part isn't so important (as i have something that works at least somewhat so far) and I don't want to look up how to do a toc right now, this is the first document I've done in latex and it is from a template that I had to do some fixes to get to work properly.

EDIT: I've seen people put the compiled results here but I can't figure out any way; how do I do that?

Ijon Tichy
Posts: 188
Joined: Mon Dec 24, 2018 10:12 am
\AddToShipoutPictureBG* adds output to the background of the next page. So this output is behind the first page of the included PDF. There is also a \AddToShipoutPictureFB* that adds output to the foreground of the next page and \AddToShipoutPictureFB (without the star) would add it so every following page.

But as I already told, you can use option pagecommand to change the page style (header and footer) of the incuded PDF pages. A simple example would be
Code: [Select all] [Expand/Collapse] [Download] (pagecommand-example.tex)
\documentclass{article}\usepackage{pdfpages}\usepackage{mwe} \begin{document} \includepdf[pages=-,  pagecommand={},% removed the default \thispagestyle{empty}]{example-image-10x16.pdf}\includepdf[pages=-,  pagecommand={},% removed the default \thispagestyle{empty}]{example-image-a.pdf} \end{document}

Now, you can see a simple page number at the center of the bottom of the page.

To move the page number to the top and the right, you can use packages like fancyhdr or scrlayer-scrpage. Here is an example with the last one:
Code: [Select all] [Expand/Collapse] [Download] (scrlayer-scrpage-example.tex)
\documentclass{article}\usepackage{pdfpages}\usepackage{lastpage}\usepackage[markcase=noupper]{scrlayer-scrpage}\clearscrheadfoot\renewcommand*{\pagemark}{\usekomafont{pagenumber}\thepage{}/\pageref{LastPage}}\ohead*{\pagemark}\setkomafont{pageheadfoot}{}% remove the \slshape from the page header/footer \usepackage{mwe} \begin{document} \includepdf[pages=-,  pagecommand={},% removed the default \thispagestyle{empty}]{example-image-10x16.pdf}\includepdf[pages=-,  pagecommand={},% removed the default \thispagestyle{empty}]{example-image-a.pdf} \end{document}

As also told, you can use option addtotoc to generate an entry to the table of contents:
Code: [Select all] [Expand/Collapse] [Download] (addtotoc-example.tex)

BTW: scrlayer-scrpage also allows to move the head towards the top of the page:
Code: [Select all] [Expand/Collapse] [Download] ({untitled.tex})
You can do similar things with the horizontal position or the width. See the KOMA-Script manual for more information.

javascripter
Posts: 3
Joined: Mon Feb 10, 2020 7:04 pm
thanks, I guess I just didn't know how to use the package I was using, that was easier than expected

I did try using the pagecommand thing, I though you needed some arguments until I saw your example (I couldn't find an example when I googled for it), as it didn't work in my case, I would guess something else in the template I'm using makes it not work, but just changing it from BG* to FG does exactly what I want.

however, addtotoc as an argument for pdfpages (I also couldn't find an example of how to put two optional arguments) works better (though I had to figure out how to get the formatting correctly with it) at linking the toc to the correct place in the document, so I use that one.

only problem now is \lastpage only seems to work for page numbering of last chapter, but it seems possible to get page numbers of any chapter, I just need to figure out how

Return to “Page Layout”

### Who is online

Users browsing this forum: No registered users and 3 guests