# position background image with \SetBgAnchor

I want to print an A4 page on B4 stock, with crop marks and bleeding square grid. I use memoir for crop marks, and background with TikZ for the grid. I would like the (0,0) in TikZ be placed at the bottom left corner: ideally of the cropped area (as I don't know how to do that, the example has it at the corner of the stock page).

I am having troubles positioning the grid relative to the where I need using the \SetBgAnchor command. The background documentation says that a typical use would be \SetBgAnchor{north east}, but that gives me

! Package pgfkeys Error: I do not know the key '/tikz/north east' and I am going to ignore it. Perhaps you misspelled it.


The code looks like this:

\documentclass[10pt,b4paper,showtrims]{memoir}
% a4 paper centerd on b4
\settrimmedsize{297mm}{210mm}{*}
\settrims{28mm}{20mm}
\trimLmarks

\usepackage{background}

\SetBgScale{1}
\SetBgAngle{0}
\SetBgColor{blue!30}
% corner left bottom, span the grid over the page
% I will need about 3mm of bleed, but that's easy once bg is positioned
\SetBgContents{\tikz{\draw[step=5mm] (28mm,20mm) grid (225mm,315mm);}}
\SetBgPosition{current page.south west}
\SetBgAnchor{}  % should be {south west}

\pagestyle{empty}

\begin{document}
Some text
\end{document}


Questions are therefore:

1. How to fix my code so that the grid is positions properly?
2. Is there a way to have to TikZ coordinates start at the bottom left corner of the cropped page rather than stock page?
-
Yes; it's a bug in background; I will correct it as soon as I can; I will give you a workarond shortly. – Gonzalo Medina Mar 13 '12 at 15:24

It is a bug in the background package (thanks for detecting it). As a workaround while I upload a new version of the package, you can pass all your options directly to \bg@material, as the following example shows (I wasn't sure about the desired grid position):

\documentclass[10pt,b4paper,showtrims]{memoir}
\settrimmedsize{297mm}{210mm}{*}
\settrims{28mm}{20mm}
\trimLmarks

\usepackage{background}

\makeatletter
\def\bg@material{%
\begin{tikzpicture}[remember picture,overlay]
\node [rotate=0,scale=1,opacity=0.6,color=blue!30,xshift=28mm,yshift=20mm]
at (current page.south west)  [anchor=south west]{\tikz{\draw[step=5mm] (28mm,20mm) grid (225mm,315mm);}};
\end{tikzpicture}}
\makeatother

\pagestyle{empty}

\begin{document}
Some text
\end{document}


Which results in:

-
Thanks. For question 2, is there no way? I can live without that, but it would be convenient. – eudoxos Mar 13 '12 at 16:40
@eudoxos: if I understand your question correctly, you can use \pgfsys@transformshift{x displacement}{y displacement} inside the tikzpicture environment: for example, \makeatletter \pgfsys@transformshift{30pt}{-100pt} \makeatother – Gonzalo Medina Mar 13 '12 at 18:07
I was thinking that background/TikZ perhaps pre-defines a rectangle for the "text area" of the page I could refer to (text area.south west). It probably does not, that is fine as well. Thanks. – eudoxos Mar 13 '12 at 18:39