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'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:

\documentclass{article}
\usepackage[final]{pdfpages}
\begin{document}
\includepdf[pages=-]{completenotes310pages.pdf}
$hello
$\end{document}

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.

share|improve this question
    
Should we assume that completenotes310pages.pdf has blank spaces where you want to put the math content? And you want to put the math content in the specific spaces using LaTeX? –  Werner Sep 3 '11 at 19:58
    
yes thats correct, it is by no means a blank file, theyre notes written by a lecturer and im trying to put my own notes over them in latex you see. –  john Sep 3 '11 at 20:00
    
so,,there is writing on each page of the pdf document but areas where i can write text and it would fit in nicely,,in other words ill be using \new line \ and \qquad alot –  john Sep 3 '11 at 20:01
2  
This seems to be a duplicate of tex.stackexchange.com/questions/15314/… –  Martin Schröder Sep 3 '11 at 20:10
    
yes it is very similar in a sense. infact im happy to go with the solution for the post providing i can get the tikz.sty or pgf style file. i just cant find it atm, erm, im just guessing there is no way to use pdfpages and overlay latex on them directly without the tikz solution then for now :).. –  john Sep 3 '11 at 20:12
add comment

1 Answer 1

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:

    \documentclass{article}
    \usepackage{pdfpages}% http://ctan.org/pkg/pdfpages
    \begin{document}
    \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)
    \end{document}
    

    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:

\documentclass{article}
\usepackage{lipsum}
\begin{document}
\lipsum[1-2]

\vspace{5cm}

\lipsum[3-4]
\end{document}

Source document

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

\documentclass{article}
\usepackage{pdfpages}% http://ctan.org/pkg/pdfpages
\usepackage{eso-pic}% http://ctan.org/pkg/eso-pic
\pagestyle{empty}
\begin{document}
% Add pages before
\AddToShipoutPictureFG*{%
  \AtPageCenter{%
    \vspace{2cm}
    \makebox[0pt][c]{\Huge HERE IS SOME TEXT.}
  }
}%
\includepdf[pages=1]{source.pdf}
% Add pages after
\end{document}

Final document

share|improve this answer
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.