[Tex/LaTex] Overlay LaTeX/TeX coding easily on PDF with 300 pages


I've been looking for a way to overlay TeX/LaTeX i.e maths language etc (everything LaTeX is designed for) onto a background document containing 310 pages combined together in a PDF file.

So far I have been eagerly under the impression it would be easy to do using pdfpages and once I had done this:


the hello would appear on a extra 311th page. Note: completenotes310pages.pdf had 310 pages.

I have noticed a person trying to do it here: How can I superimpose LaTeX / TeX output over a PDF file? but it wasn't clear if he had one PDF page or two or more in his PDF file.

I'm currently looking to install the tikz.sty file but can't find it. I'll keep this updated with my anticipation etc.

Best Answer

Here are a couple of suggestions:

  • When using pdfpages each included page will be scaled from the source document - completenotes310pages.pdf in your case - to the destination document <jobname>.pdf unless you specify the noautoscale key. Even if you do not specify this, or if the pages you're importing are of the exact size that you're currently working on, once a page is full, LaTeX will ship it out, and move on to the following page. This is the case with the MWE, even though you had hoped hello would be printed on page 1. This leads to the following suggestion...

  • You will have to include the pages on an as-needed basis in order to "pause" LaTeX momentarily and add content to the page. For example, you may have a document sequence that looks like this:

    \usepackage{pdfpages}% http://ctan.org/pkg/pdfpages
    \includepdf[pages=1-5]{completenotes310pages.pdf}% Includes pages 1-5 (no additions on these pages)
    <some stuff>
    \includepdf[pages=6]{completenotes310pages.pdf}% Includes page 6
    <some more stuff>
    \includepdf[pages=7-310]{completenotes310pages.pdf}% Includes pages 7-310 (no additions on these pages)

    where <some stuff> and <some more stuff> detail your mathematical addition.

  • If the original document is NOT typeset in LaTeX, and it has whitespace that is actually a picture, you may have to typeset the page in the background, before overlaying it with LaTeX mathematics. For this, I would suggest using the everyshi package that provides \AtNextShipout{...} or the eso-pic package command \AddToShipoutBG{...}. Actually, I think the latter option would work better in this case. And you could switch to using the foreground or background options ...FG or ...BG depending on whether you're placing the math content or the page.

Here is a practical example illustrating some of the suggestions above:

Consider the following source document, called source.tex and output source.pdf:




Source document

You'll notice the gap that requires some filling. This is how I would do it:

\usepackage{pdfpages}% http://ctan.org/pkg/pdfpages
\usepackage{eso-pic}% http://ctan.org/pkg/eso-pic
% Add pages before
    \makebox[0pt][c]{\Huge HERE IS SOME TEXT.}
% Add pages after

Final document

Related Question