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
Page Layout ⇒ Proper way to include a pdf as an appendix
-
- Posts: 3
- Joined: Mon Feb 10, 2020 7:04 pm
NEW: TikZ book now 40% off at Amazon.com for a short time.
- Ijon Tichy
- Posts: 640
- Joined: Mon Dec 24, 2018 10:12 am
Proper way to include a pdf as an appendix
Usually
Why don't you use the
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.
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

Sorry, but I can no longer participate here as the administrator is trampling on my wishes on one of his other platforms. 

-
- Posts: 3
- Joined: Mon Feb 10, 2020 7:04 pm
Proper way to include a pdf as an appendix
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:
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?
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: 640
- Joined: Mon Dec 24, 2018 10:12 am
Proper way to include a pdf as an appendix
\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, edit and compile here:
\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}
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, edit and compile here:
\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}
addtotoc
to generate an entry to the table of contents:
Code, edit and compile here:
\documentclass{article}\usepackage{pdfpages}\usepackage{lastpage}\usepackage[automark,markcase=noupper]{scrlayer-scrpage}\clearscrheadfoot\renewcommand*{\pagemark}{\usekomafont{pagenumber}\thepage{}/\pageref{LastPage}}\ihead{\headmark}% Don't use the star version here!\ohead*{\pagemark}\setkomafont{pageheadfoot}{}% remove the \slshape from the page header/footer\usepackage{mwe}%\pagestyle{plain}% Please, try out the difference with this command.\begin{document}\tableofcontents\blinddocument\appendix% Standard LaTeX command to begin the appendix\renewcommand*{\sectionmark}[1]{\markright{\MakeMarkcase{Appendix \thesection: #1}}}% running heads of appendices with prefix\includepdf[pages=-,pagecommand={},% removed the default \thispagestyle{empty}addtotoc={1,section,1,{10x16-Image},{sec:10x16}}]{example-image-10x16.pdf}\includepdf[pages=-,pagecommand={},% removed the default \thispagestyle{empty}addtotoc={1,section,1,{A-Image},{sec:A}}]{example-image-a.pdf}\includepdf[pages=-,pagecommand={},addtotoc={1,section,1,{Colored Pages},{sec:colorpages}}]{example-image-letter-numbered}\end{document}
Code: Select all
Code, edit and compile here:
\documentclass{article}\usepackage{pdfpages}\usepackage{lastpage}\usepackage[markcase=noupper,automark]{scrlayer-scrpage}\clearscrheadfoot\renewcommand*{\pagemark}{\usekomafont{pagenumber}\thepage{}/\pageref{LastPage}}\ihead{\headmark}% dont't use the star-version here!\ohead*{\pagemark}\setkomafont{pageheadfoot}{}% remove the \slshape from the page header/footer\usepackage{mwe}\begin{document}\tableofcontents\blinddocument\appendix% Standard LaTeX command to begin the appendix\renewcommand*{\sectionmark}[1]{\markright{\MakeMarkcase{Appendix \thesection: #1}}}% Add prefix "Appendix" before the number in the running head generation\ModifyLayer[voffset=\headheight]{scrheadings.head.oneside}% Change vertical position of scrheadings head\ModifyLayer[voffset=\headheight]{plain.scrheadings.head.oneside}% Change vertical position of corresponding plain head\includepdf[pages=-,pagecommand={},% removed the default \thispagestyle{empty}addtotoc={1,section,1,{10x16-Image},{sec:10x16}}]{example-image-10x16.pdf}\includepdf[pages=-,pagecommand={},% removed the default \thispagestyle{empty}addtotoc={1,section,1,{A-Image},{sec:A}}]{example-image-a.pdf}\includepdf[pages=-,pagecommand={},addtotoc={1,section,1,{Colored Pages},{sec:colorpages}}]{example-image-letter-numbered}\end{document}
Sorry, but I can no longer participate here as the administrator is trampling on my wishes on one of his other platforms. 

-
- Posts: 3
- Joined: Mon Feb 10, 2020 7:04 pm
Proper way to include a pdf as an appendix
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
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