3

I would like to write a book in which the whole text is progressively, so the beginning is black and the end is light gray. A page scale approach seems inaccurate and all the examples I can get for now does not scale to the book scale.

Any ideas ?

  • Welcome to TeX.SX! Do you want to change the color page-wise or check with every letter? – TeXnician Jan 16 '18 at 11:48
  • Would it be enough to change the textcolor for e.g. every page or maybe every paragraph? For example \afterpage could be used to set the text color lighter one step per page. A similar approach can be implemented on a per-paragraph level. If not some TikZ wrapping code with fading effects could be used, but the textcolor approach is easier and better in my opinion. – Martin Scharrer Jan 16 '18 at 11:48
  • @martin-scharrer Thanks for your fast feedback! I appreciate it. The paragraph approach will be good enough for my purpose. But I am curious to discover the character one. – Stéphane Mourey Jan 16 '18 at 12:33
  • @TeXnician My previous answer to Martin is for you too, but notifications to more than one user are not allowed... – Stéphane Mourey Jan 16 '18 at 12:35
  • @StéphaneMourey: There is a per-page and a per-paragraph solution, as both have hooks in TeX which can be used. You can't do it per-character, only as shading effect overlaying the text, i.e. the color would change over single characters as well. – Martin Scharrer Jan 16 '18 at 12:47
  • @MartinScharrer Please, let me know the per paragraph solution... – Stéphane Mourey Jan 16 '18 at 13:12
  • 1
    In any case, the human eye would not be able to detect changes that small. Even the paragraph solution is probably pushing it. The main problem with the page solution is that a split paragraph at the top of a page will be slightly darker than the rest of the page. – John Kormylo Jan 16 '18 at 15:56
  • @JohnKormylo It seems that page and paragraph solutions are nearly the same, but I really would like to know one of those... – Stéphane Mourey Jan 16 '18 at 16:15
  • If your book is a PDF e-book, OK. But if your book is to be printed to paper, then what you seek to do is not a good idea. There are many reasons, having to do with commercial print technology. –  Jan 16 '18 at 17:52

1 Answers1

5

Here is a proposal that adds some transparent white foreground which gets less and less transparent.

\documentclass{article}
\usepackage{lipsum}
\usepackage{tikz}
\usetikzlibrary{fadings,shadings}
\usepackage{eso-pic}
\usepackage{lastpage,refcount}
\def\finaltrans{0.5} % adjust this value to make the end more or less transparent
\begin{document}

\newcounter{lastpagenumber}%
\setcounter{lastpagenumber}{\getrefbykeydefault{LastPage}{page}{1}}%
\AddToShipoutPictureFG{% Add picture to background of every page
  \AtPageLowerLeft{%
        \makebox[\paperwidth]{
        \begin{tikzpicture}
        \pgfmathsetmacro{\opaone}{100*(1-\finaltrans*(\thepage)/(\thelastpagenumber+1))}
        \pgfmathsetmacro{\opatwo}{100*(1-\finaltrans*(\thepage+1)/(\thelastpagenumber+1))}
        \tikzfading[name=fade down \thepage,
            top color=transparent!\opaone,
            bottom color=transparent!\opatwo]
        \fill[white,path fading=fade down \thepage] (0,0) rectangle (\paperwidth,\paperheight);
        \end{tikzpicture}}%
  }%
}


\lipsum[1-20]
\end{document}

You can adjust \finaltrans in order to control how gray the final page will be.

Here is an example with two pages and \finaltrans 0.9.

enter image description here