# How to cover certain area of included pdf pages with white rectangle?

I have a bunch of handwritten notes that I'd like to integrate with my other notes typesetted with latex.

And to give the integrated notes a clear structure, I am wishing to typeset the section names on the included pages, so that the contents of the included pages could also be indexed by latex and referred to at somewhere else in the document.

Luckily pdfpages let me do this with pagecommand.

But the thing is, since there are the original handwritten section names on the included scanned pages, simply overlapping the latex section names on top would only make both unreadable. So I am wondering if there are ways that I can somehow "delete" the old, handwritten stuff first and then replace them with latex typesetting? Maybe draw a white polygon over the area of interest?

Because when I wrote the notes, I did write all the section names on roughly the same position of the pages, so hard-code the coordinates of the areas is feasible if needed.

• Welcome to TeX.SE! You can certainly do something along these lines with eso-pic. Just place a white area on the surface of the page. Frankly, rather than doing that, though, I'd like to encourage you to active consider typing up the notes. On the long run, you and your readers will benefit from it. – marmot Oct 6 '18 at 3:03
• Another solution is probably to set latex titles to be transparent. In this way you don't have to adjust anything, the titles will be searchable and you can copy/paste them from the pdf, and they can appear (non transparent) in your table of contents. – Kpym Oct 6 '18 at 5:46

What about putting the PDF in the background? Then put section headings (or other content) in white boxes over the top using tcolorbox?

# MWE

(Disclaimer: I maintain the pdfoverlay package which provides a convenient interface for putting PDFs in the background and overlaying anything over the top.)

\documentclass{article}
\usepackage{pdfoverlay}
\usepackage{tcolorbox}
\newcommand{\whitebox}[2][]{%
\begin{tcolorbox}[colback=white,frame empty,left=0pt,right=0pt,top=0pt,
bottom=0pt,boxsep=2pt,grow to left by=2pt,grow to right by=2pt,#1]
#2
\end{tcolorbox}}
\begin{document}
\pagestyle{empty}
\pdfoverlaySetPDF{example-image.pdf}
\tableofcontents
\vspace*{2cm}