Currently I am using an external PDF image to get a color gradient provide in the margins. See the output below. I achieve this by using command \ULCornerWallPaper{1}{./pictures/wallpaper_1.pdf}
However, this method is very inefficient because importing the external picture every time results in a long compilation time. Is there a better way of doing it?
The gradient is only applied to some of the pages so it would be ideal if you provided me with a solution which I can include in \ULCornerWallPaper{1}{}
so I can undo gradient after a while using command \ClearWallPaper
.
Could I achieve this using tikz
? I'm not very familiar with it, but it looks like a possible tool for solving my problem.
Best Answer
The solution below defines two alternative ways of drawing a coloured gradient in the margin background on a selection of pages:
\conditionalmarginbg
(which takes no argument) at the beginning of your document and then toggle the margin background on/off in your document by using the\startdrawmarginbg
and\stopdrawmarginbg
macros.\marginbgpagelist
at the beginning of your document; its only argument is a list of pages on which to draw a margin background. That list usespgffor
's\foreach
syntax, so you can specify10,...,20
to draw a margin back on pages 10 to 20.In the example below, I used
\conditionalmarginbg
and, for visualisation, I emphasised (red, bold text) where\startdrawmarginbg
and\stopdrawmarginbg
are invoked.Notes:
pdflatex
no fewer than 3 times to get the correct output.oneside
class option. It works fine withtwoside
, though.References: