1

I tried to adapt How to add “DRAFT” along the left/right margin? to have symmetrical "DRAFT"s along both margins, one running down the right margin, and one running down the left margin. Trying the obvious thing of using \backgroundsetup twice doesn't work - only the second one is printed.

I tried an approach based on How do you add multiple watermarks?, but had trouble getting it to work.

Here is my code based on the approach described in How to set two backgrounds?:

I tried replacing (0,0) with current page.east, but the watermark disappeared. How do I get something similar to the example in How to set two backgrounds??

I'm open to other approaches to this.

\documentclass{article}
\usepackage{lipsum}
\usepackage{background}

\backgroundsetup{
  angle=0,
  opacity=1,
  scale=3,
  contents={%
\begin{tikzpicture}[remember picture,overlay]
\node[text=gray,rotate=-90,anchor=east, yshift=5mm] at (0,0) {DRAFT1};
\node[text=gray,rotate=90,anchor=west, yshift=5mm] at (0,0) {DRAFT2};
\end{tikzpicture}}
}

\begin{document}
  \lipsum
\end{document}

1 Answer 1

3

You can use the tikzpagenodes package to easily access the textarea as a node.

Code

\documentclass{article}
\usepackage{tikz}
\usepackage{background}
\usepackage{tikzpagenodes}
\usepackage{lmodern}

\usepackage{lipsum}

\backgroundsetup%
{   angle=0,
    opacity=1,
    scale=1,
    contents=%
    {   \begin{tikzpicture}[remember picture,overlay, scale=3]
            \fontsize{100}{120}\selectfont
            \node[text=gray!50!red,rotate=90, above=1cm] at (current page text area.west) {DRAFT 1};
            \node[text=gray!50!blue,rotate=-90, above=1cm] at (current page text area.east) {DRAFT 2};          
        \end{tikzpicture}
    }
}

\begin{document}

\lipsum \lipsum

\end{document}

Output

enter image description here


Edit 1: You can also place the "Draft" watermarks automatically in the middle of the margin. I assume you want them to be centered at the text area rather than the page area. While for most cases it will be almost the same, I constructed an extreme case to show the differences.

Here, the top margin is only 5mm while the bottom margin is 90mm. This leads to current page.west (orange dot) being at a much lower position than current page text area.west (green dot). So if one simply computes the midpoint via the calc library's (A)!0.5!(B) one arrives at a quite low postition (blue dot). To work around that, one can use a special syntax:

In general, the meaning of (p |- q) is “the intersection of a vertical line through p and a horizontal line through q.”

With this syntax, one can compute the position of a coordinate that runs vertically through current page.west and horizontally through current page text area.west (black dot). Then one can use the midpoint of this position and current page text area.west to find the final position where the watermark will be placed (red dot).

Code

\documentclass{article}
\usepackage[inner=30mm, outer=50mm, top=5mm, bottom=90mm, twoside]{geometry}
\usepackage{tikzpagenodes}
\usepackage{background}

% for coordinate computations
\usetikzlibrary{calc}

% allows for arbitrarily large font sizes
\usepackage{lmodern}

% dummy text
\usepackage{lipsum}

\backgroundsetup%
{   angle=0,
    opacity=1,
    scale=1,
    color=black,
    contents=%
    {   \begin{tikzpicture}[remember picture,overlay]
            \fontsize{80}{108}\selectfont
            % nodes for illustration purposes
            \node[circle,minimum width=4mm,fill=green] (PTAW) at (current page text area.west) {};
            \node[circle,minimum width=4mm,fill=orange] (PW) at (current page.west) {};         
            \node[circle,minimum width=4mm,fill=red] (BMW) at ($(current page text area.west -| current page.west)!0.5!(current page text area.west)$) {};
            \node[circle,minimum width=4mm,fill=blue] (GMW) at ($(current page.west)!0.5!(current page text area.west)$) {};
            \node[circle,minimum width=4mm,fill=black] (GW) at (current page text area.west -| current page.west) {};
            % the watermarks
            %\node[text=gray,rotate=90] at ($(current page text area.west -| current page.west)!0.5!(current page text area.west)$) {DRAFT 1};
            \node[text=gray,rotate=-90] at ($(current page text area.east -| current page.east)!0.5!(current page text area.east)$) {DRAFT 2};          
        \end{tikzpicture}
    }
}

\begin{document}

\lipsum \lipsum

\end{document}

Output

enter image description here

8
  • That looks good, thanks. Do you understand why my earlier attempt was not working? I.e. why current page.east does not work, for example? Nov 29, 2015 at 23:36
  • @FaheemMitha: In your (0,0) approach, the "Draft" is placed at the center of the page, as expected. But as you use scale=3, the positions of the nodes are shifted, so they are far outside your page. Try with scale=1 and plae "Draft1" west and "Draft2" east. Nov 29, 2015 at 23:58
  • @FaheemMitha: Also, you made me realize how idiotic this whole (north east)!0.5!(south east) business is, if one can just use (east). D'oh! I updated the answer accordingly. Nov 30, 2015 at 0:05
  • Well, current page.east does not work, but your current page text area.east does. I'm not sure what the differences between those are. Nov 30, 2015 at 8:14
  • Actually, it would nice to have an automated way to have the text located at the midpoint of the margin width, rather than having to adjust it manually. Nov 30, 2015 at 8:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .