1

I am wondering if there are already some tools in TeX available that can handle the following problem. If not, I believe there is a possibility to do this. I want to overlay a transparent-to-white picture onto some pages of my document; as it is done in a lot of journals. Thus, the reader can start reading the, e.g., first paragraph while a full read needs the original document. Some example:

\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{blindtext}
\usepackage{tikz}
\newcommand{\blend}
{
    \begin{tikzpicture}[remember picture, overlay]
    \node[inner sep=0pt] at (current page.center)
    {%
        \includegraphics[width=\paperwidth,height=\paperheight]{blend}%
    };%
    \end{tikzpicture}%
}

\begin{document}
\blindtext[4]
\blend
\blindtext[4]
\blend
\end{document}

The blend.png file is just a picture with a transparent-to-white color gradient. However, as one can see, the overlay does not cover the whole page (the second \blindtext[4] on the first page is visible). Furthermore, it would be nice to construct a new command that stores the page numbers where the overlay should happen. Additionally, rather than inserting a *.png file, I guess it would be better to use tikz directly (smaller files). enter image description here

However, I am thinking, that creating the PDF without the overlay while modifying it afterward (e.g. using convert) may be a better approach? Any hint is appreaciated.

Tobi
  • 447
  • Do you want something like this or fade each individual page? –  Nov 02 '19 at 19:01
  • Personally, I would like to fade chapter-wise. E.g., chapter 1 no fade, chapter 2-3 fade each page or fade after the 5th page. I guess your second tex codeis a good starting point. – Tobi Nov 02 '19 at 20:17
  • 1
    Below is a way that does that on a page by page basis. (Please note, though, that whatever you do, if you send the pdf that results from a LaTeX compilation to someone, they will still be able to extract the text.) –  Nov 02 '19 at 20:22
  • Dear @Schrödinger'scat, thanks for the comment. Just tried the code below and it does exactly what I want to do. – Tobi Nov 02 '19 at 20:26
  • @Schrödinger'scat, I guess you mean something like "pdf2txt". That's fine for me. – Tobi Nov 02 '19 at 20:33
  • Yes, the text is still in the file, and can be extracted e.g. with pdf2txt, as you say. –  Nov 02 '19 at 20:37

1 Answers1

1

Here is something that does it. It is very similar to this answer but does the fading on a page per page basis.

\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{blindtext}
\usepackage{eso-pic}
\usepackage{tikz}
\usetikzlibrary{fadings}
\newcommand{\blend}
{
\begin{tikzpicture}[remember picture, overlay]
    \tikzfading[name=fade page,
        top color=transparent!100,
        bottom color=transparent!0]
    \fill[white,path fading=fade page] (0,0) rectangle (\paperwidth,\paperheight);
\end{tikzpicture}%
}

\begin{document}
\blindtext[12]
\clearpage
\AddToShipoutPictureFG{\blend}%<- start faded pages (you may put this before \begin{document})
\blindtext[12]
\clearpage
\ClearShipoutPictureFG%<- end faded pages
\blindtext[12]
\end{document}

enter image description here

It is possible to make the fading such that it already fades away in the middle.

\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{blindtext}
\usepackage{eso-pic}
\usepackage{tikz}
\usetikzlibrary{fadings}
\newcommand{\blend}
{
\begin{tikzpicture}[remember picture, overlay]
    \tikzfading[name=fade page,
        top color=transparent!100,
        bottom color=transparent!0,
        middle color=transparent!0]
    \fill[white,path fading=fade page] (0,0) rectangle (\paperwidth,\paperheight);
\end{tikzpicture}%
}

\begin{document}
\blindtext[12]
\clearpage
\AddToShipoutPictureFG{\blend}%<- start faded pages (you may put this before \begin{document})
\blindtext[12]
\clearpage
\ClearShipoutPictureFG%<- end faded pages
\blindtext[12]
\end{document}

enter image description here

  • 1
    Thanks. Works perfectly. I put the \AddToShipoutPictureFG{\blend} and the \ClearShipoutPictureFG into two new commands named \startFade and \endFade. Perfect solution. Thank you very much. – Tobi Nov 02 '19 at 20:29
  • One question as I am not familiar with the \fill option in tikz. It should be possible to modify it such as \draw (0,0) rectangle (2,2) node [center] {Test};. However, with the \fill option it does not work. – Tobi Nov 02 '19 at 20:55
  • @Tobi You can just add after the \fill...; command \path (current page.center) node{bla};. –  Nov 02 '19 at 21:00