Here is a simple example that illustrates the problem.
The file hello.tex is used with pdflatex to create the file hello.pdf.
That PDF file is then included in demo.tex as shown. Pdflatex is then
used to create demo.pdf. I expect the framed box containing hello.pdf
to appear after the first paragraph and before the second paragraph.
Instead, "hello, world" appears after the last word of the first
paragraph, raised a bit above the baseline, the top line of the frame
appears on top of the seventh line of the first paragraph, and the
bottom line of the frame appears well below the bottom of the second
paragraph.
------------------------------ hello.tex -------------------------------
\documentclass{article}
\begin{document}
hello, world
\end{document}
------------------------------- demo.tex -------------------------------
\documentclass{article}
\usepackage{pdfpages}
\usepackage{lipsum}
\begin{document}
\lipsum[1]
\begin{figure}[hb]
\includepdf[pages=-,frame,width=7.5in,trim=0in 5.0in 0in 1.0in,clip]{hello.pdf}
\end{figure}
\lipsum[2]
\end{document}
------------------------------------------------------------------------
Is this a bug or something I'm doing wrong? If the latter, how should I
be doing this?
I'm using MiKTex on Windows XP.
--
Gary Johnson
You are using your included PDF in a float. Miss out the
\begin{float} ... \end{float} business, and just put \includepdf
directly in your document.
--
Joseph Wright
> I'm having a problem using the \includepdf command of the pdfpages
> package. When I include a PDF file using the \includepdf command, the
> included file is laid on top of the other text in the document rather
> than being inserted between the preceding and following text.
> \begin{figure}[hb]
> \includepdf[pages=-,frame,width=7.5in,trim=0in 5.0in 0in 1.0in,clip]{hello.pdf}
> \end{figure}
Remove the figure environment.
If you want to fill the page before, try
\usepackage{afterpage}
\afterpage{\includepdf[...]{hello.pdf}}
--
Heiko Oberdiek
Thank you. I had done that at first and that had caused a different
problem, demonstrated here. Using the following version of demo.tex,
------------------------------------------------------------------------
\documentclass{article}
\usepackage{pdfpages}
\usepackage{lipsum}
\begin{document}
Just a one-line paragraph.
\includepdf[pages=-,frame,width=7.5in,trim=0in 8.0in 0in 1.0in,clip]{hello.pdf}
A second one-line paragraph.
\end{document}
------------------------------------------------------------------------
there is plenty of room on the page for both paragraphs and the included
PDF page, yet the resulting document, demo.pdf, has the first paragraph
on page 1, the included PDF page centered on page 2, and the third
paragraph on page three. I found that by putting the included PDF page
within a figure environment, I could get the included PDF page on the
same page as other text, and that worked fine in my application for a
while, but then I encountered the overlaying problem I described in my
first post.
--
Gary Johnson
> \documentclass{article}
> \usepackage{pdfpages}
> \usepackage{lipsum}
> \begin{document}
>
> Just a one-line paragraph.
>
> \includepdf[pages=-,frame,width=7.5in,trim=0in 8.0in 0in 1.0in,clip]{hello.pdf}
>
> A second one-line paragraph.
>
> \end{document}
> ------------------------------------------------------------------------
>
> there is plenty of room on the page for both paragraphs and the included
> PDF page, yet the resulting document, demo.pdf, has the first paragraph
> on page 1, the included PDF page centered on page 2, and the third
> paragraph on page three. I found that by putting the included PDF page
> within a figure environment, I could get the included PDF page on the
> same page as other text, and that worked fine in my application for a
> while, but then I encountered the overlaying problem I described in my
> first post.
Why are you using \includepdf at all? For images use something like
\usepackage{graphicx}
\begingroup
\setlength{\fboxsep}{0pt}%
\fbox{%
\includegraphics[
% page=1,
% option page allows for pdfTeX
% the selection of other pages
width=7.5in,
keepaspectratio,
trim=0 8in 0 1in,
clip
]{hello.pdf}%
}%
\endgroup
This you can also put into a float environment (figure) and you can
add a caption; float environments (figure, table, ...) are limited to
one page.
--
Heiko Oberdiek
Thanks, but that didn't work, either. With that I get the two
paragraphs on page 1 and the included PDF page on page two.
Adding \clearpage, like this,
\afterpage{\clearpage\includepdf[...]{hello.pdf}}
gave the same results, as did further adding a figure environment, like
this:
\afterpage{\clearpage\begin{figure}[h]\includepdf[...]{hello.pdf}\end{figure}}
--
Gary Johnson
> Heiko Oberdiek <heiko.o...@googlemail.com> wrote:
> > Gary Johnson <gary...@eskimo.com> wrote:
> >
> > > I'm having a problem using the \includepdf command of the pdfpages
> > > package. When I include a PDF file using the \includepdf command, the
> > > included file is laid on top of the other text in the document rather
> > > than being inserted between the preceding and following text.
> >
> > > \begin{figure}[hb]
> > > \includepdf[pages=-,frame,width=7.5in,trim=0in 5.0in 0in 1.0in,clip]{hello.pdf}
> > > \end{figure}
> >
> > Remove the figure environment.
> > If you want to fill the page before, try
> > \usepackage{afterpage}
> > \afterpage{\includepdf[...]{hello.pdf}}
>
> Thanks, but that didn't work, either. With that I get the two
> paragraphs on page 1 and the included PDF page on page two.
Then it works as expected.
Probably you are looking for \includegraphics, see package graphicx
and its documentation in grfguide.
--
Heiko Oberdiek
I first wanted to include images of a three-page PDF document in my
document. A Google search found the pdfpages package which claimed to
avoid some of the problems of \includegraphics. It turned out to work
perfectly for that application.
Then I discovered another PDF document I wanted to include, but it was
only about a half page long. Because I had already successfully used
pdfpages, I just continued to use it instead of looking for something
else.
> For images use something like
>
> \usepackage{graphicx}
>
> \begingroup
> \setlength{\fboxsep}{0pt}%
> \fbox{%
> \includegraphics[
> % page=1,
> % option page allows for pdfTeX
> % the selection of other pages
> width=7.5in,
> keepaspectratio,
> trim=0 8in 0 1in,
> clip
> ]{hello.pdf}%
> }%
> \endgroup
>
> This you can also put into a float environment (figure) and you can
> add a caption; float environments (figure, table, ...) are limited to
> one page.
Between posts here, I did some more searching and reading and discovered
a solution much like yours.
\noindent
\begin{list}{}{\setlength{\leftmargin}{-1.25in}}
\setlength{\fboxsep}{0pt}
\item%
\fbox{\includegraphics[width=7.5in,trim=0in 8.0in 0in 1.0in,clip]{hello.pdf}}
\end{list}
I'm glad to see that I was on the right track with that. The reason for
the list environment was to temporarily change the left margin for this
insertion, since it is so wide.
Thank you very much for your help.
--
Gary Johnson