I am using newlfm
for a document and am also loading pdfpages
to append some external PDF files to the end of this document. My problem is that I get a blank page at the end of the document, traceable to newlfm
. If I omit the {newlfm}
environment the blank page disappears — but of course that environment is necessary in order for the documentclass to format the page properly.
Here is a MWE:
**external.tex**:
\documentclass{article}
\begin{document}
This is an external file.
\end{document}
**wrapper.tex**:
\documentclass{newlfm}
\usepackage{pdfpages}
\begin{document}
\begin{newlfm}
This is a nicely formatted introductory page.
\includepdf{external.pdf}
\end{newlfm}
\end{document}
The above produces a three-page wrapper.pdf
, when it should contain only two pages.
Can anyone help?
UPDATE
Per @jon's request, here is a second MWE that illustrates the header problem when the inclusion of the PDF is invoked outside the newlfm
environment:
**wrapper2.tex**:
\documentclass[stdletternofrom]{newlfm}
\Lheader{Left Header}
\lheader{second-page left header}
\Rheader{Page \thepage}
\rheader{Page \thepage}
\usepackage{pdfpages}
\newcounter{includepdfpage}
\newcounter{currentpagecounter}
\newcommand{\addlabelstoallincludedpages}[1]{%
\refstepcounter{includepdfpage}%
\stepcounter{currentpagecounter}%
\label{#1.\thecurrentpagecounter}}
\newcommand{\modifiedincludepdf}[2]{%
\includepdf[pages=-,pagecommand=\addlabelstoallincludedpages{#1}]{#2}%
}
\begin{document}
\begin{newlfm}
This is a nicely formatted introductory page.
\modifiedincludepdf{ExtFile}{external.pdf}
\end{newlfm}
\end{document}
If \end{newlfm}
is moved above \modifiedincludepdf
, instead of the second-page header appearing on Page 2, the first-page header is there and is in the wrong location.
Best Answer
Yes Brian, I reproduced your problem while using
newlfm
. Luckily, in your case, as long as you issue a\AtBeginShipout\AtBeginShipoutDiscard
right after the<filename.pdf>
, it fixes the problem.In the past, I noticed the
newlfm
package has serious issues with these extra pages, that unfortunately, even after issuing a\clearpage
simply do not resolve the issue.So, say for example, and only for demonstration purposes, a pdf file is created by:
Then a total of 2 pages are created. But when you include the above file in your MWE, an unwanted page results, if you don't issue
\AtBeginShipout\AtBeginShipoutDiscard
The following is the correct solution. Please note that the option
pages=-
, was used, as thepdfpages
manual states, so all the pages that resulted from the aforementioned file, are included in the document.