Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
    
Can't you just switch the order of \includepdf{external.pdf} and \end{newlfm}? –  jon Jan 9 '13 at 21:37
    
@jon: No, I had already tried that; it messes with the page headers invoked by the pagecommand option of \includepdf (not shown in the MWE for the sake of brevity). –  Brian Jan 9 '13 at 22:08
    
Ah, well, then we need a fuller 'minimal working example' (and maybe description of what the desired output is). That is, what page headers do you need and where? –  jon Jan 9 '13 at 22:10
    
@jon: See updated question with more extensive MWE. –  Brian Jan 10 '13 at 12:21
    
Sorry, I can't explain the interaction between the two, especially since I've never really used or liked newlfm. My quick solution would be to use pdftk and just cut away the offending page, but it might be worth bringing to the attention of the newlfm author if no one answers here. –  jon Jan 11 '13 at 17:25
add comment

2 Answers 2

up vote 1 down vote accepted

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:


\documentclass{article}
\usepackage{kantlipsum}
\begin{document}
\kant[1-5]
\end{document}

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 the pdfpages manual states, so all the pages that resulted from the aforementioned file, are included in the document.


\documentclass[]{newlfm}
\usepackage{pdfpages}

\begin{document}
\begin{newlfm}
This is a nicely formatted introductory page.
\includepdf[pages=-]{akantsample.pdf}\AtBeginShipout\AtBeginShipoutDiscard
\end{newlfm}
\end{document}

enter image description here enter image description here enter image description here

share|improve this answer
    
It works -- thank you!!!! Fantastic! –  Brian Jul 7 at 17:43
    
Anytime! Glad it worked for you. –  doed Jul 8 at 11:53
add comment

As far as your mock documents go, this works well enough:

External file:

\documentclass{article}
\begin{document}
This is an external file.
\end{document}

Main file:

\documentclass{newlfm}
\usepackage{pdfpages}
\begin{document}
\begin{newlfm}
This is a nicely formatted introductory page.
\end{newlfm}
\includepdf{external.pdf}
\end{document}

I get a one page letter followed by the other .tex file (two pages total).

share|improve this answer
    
See my updated question for an example of why this doesn't solve my problem. –  Brian Jan 11 '13 at 13:13
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.