rpgtex/DND-5e-LaTeX-Template

Compatibility issue with pdfpages

albertotonda opened this issue · 3 comments

I have been using your template for a while on Overleaf with pdflatex, and it's great! However, I discovered a weird issue: when adding pages from another PDF document, using the \includepdf command from the pdfpages package, if the option bg in the dndbook class is set to full (as it is by default), the background image (e.g. img/paper.jpg) is rendered ON TOP of the the included PDF images, hiding the content. By setting bg=none or bg=print, the issue disappears.

I looked into the dndheader.sty, and it looks like that the code adding the background figure is on lines 36-44:

% Header is used to include the page background
\fancyhead{
\bool_if:NT \l__dnd_show_background_bool
{
\begin{tikzpicture}[rememberpicture,overlay]
\node[inner
sep=0pt] at (current~page.center) {\includegraphics[width=\paperwidth,height=\paperheight]{img/paper}};
\end{tikzpicture}
}
}

Unfortunately I am not familiar with the packages used: is it possible that there is a mistake somewhere that creates this (I assume incorrect) behavior?

I actually found the solution. The issue was that in dndheader.sty, on line 70, the pagestyle{empty} was defined as:

\fancypagestyle{empty}{%
  \fancyfoot{}
}

So, the pagestyle was resetting only the footer, and not the header (who inserts the background image): while adding

\fancypagestyle{empty}{%
  \fancyhead{}\fancyfoot{}
}

solves the issue, because it also resets the header, removing the background from pages with \thispagestyle{empty}

Apologies for the long delay. Life has been hectic.

I think your best option would be to add a new page style for included pdf pages. See section 12 of the fancyhdr documentation. https://texdoc.org/serve/fancyhdr/0

You switch to that page style before including the PDFs, and back to fancy when you are done.

Adding a concrete example of how I handle this:

% In pre-amble
\fancypagestyle{cover}{\fancyhf{}}
% Later in the document
\includepdf[pagecommand={\thispagestyle{cover}}]{img/full-page-pdf}

As the same implies, I mainly use the style for covers, which I render as follows:

\null%
\includepdf[pagecommand={\thispagestyle{cover}}]{cover}%
{\let\newpage\relax\maketitle}