# Geometry and layouts - problem with crop marks and Tikz current page

The issue is as follows:

1. I am laying out an approximately square page on A3 stock using geometry.
2. Because it is duplexed, it has to be centered and the cropping is critical
3. If the layout does not go to the paper edge there is not an issue. MWE1

\documentclass[a4paper]{book}

\usepackage{lipsum}
\usepackage{geometry}

\geometry{twoside=true,landscape,%
layoutwidth=300mm,layoutheight=217mm,layouthoffset=60mm,layoutvoffset=30mm,showcrop,showframe,
bindingoffset=5mm,left=32mm, textwidth=197mm,marginparsep=4mm,marginparwidth=47mm,%
a3paper,}
\begin{document}
\lipsum[1]
\end{document}


1. However I think it is often the case that layouts within bigger stock will extend to the full dimension of the stock along one axis (so only 2 cuts needed). In this case the crop marks are not really usable, and the critical part of them falls off the stock (and won't print either as it is on the paper edge): MWE2

    \geometry{twoside=true,landscape,%
layoutwidth=300mm,layoutheight=297mm,layouthoffset=60mm,layoutvoffset=0mm,showcrop,showframe,
bindingoffset=5mm,left=32mm, textwidth=197mm,marginparsep=4mm,marginparwidth=47mm,%
a3paper,}


So I want to create some sort of crop mark at the layout edge (even a small dot or a line segment ending at the edge. How can I do this? I really want to manage the layout with geometry and not with the crop package.

I thought to use Tikz to draw something, but this raises another issue with setting a layout with geometry. Tikz "current page" does not locate to the page layout but rather to the stock edges (as shown in MWE below). So this also breaks all my existing Tikz code that uses the page position. How to correct for this as well as produce the crop mark at the page edge as opposed to the paper edge. MWE3

\documentclass[a4paper]{book}

\usepackage{lipsum}
\usepackage{geometry}
\usepackage{tikz}

\geometry{twoside=true,landscape,%
layoutwidth=300mm,layoutheight=297mm,layouthoffset=60mm,layoutvoffset=0mm,showcrop,showframe,
bindingoffset=5mm,left=32mm, textwidth=197mm,marginparsep=4mm,marginparwidth=47mm,%
a3paper,}

\begin{document}

\lipsum[1]

\tikz[remember picture,overlay] {%
\draw [blue,line width=5mm]
(current page.south west)
rectangle
(current page.north east)
}%

\end{document}


Using egreg's answer to How to print (or use) the values of geometry properties in document page? and the node definition macro in tikzpagenodes, I've defined nodes corresponding to the layout area. These are automatically calculated using the paper and layout dimensions. The first page uses your MWE1 geometry, and the second page uses your MWE2 geometry.

\documentclass[a4paper]{book}
\usepackage{lipsum}
\usepackage{geometry}
\usepackage{tikzpagenodes}
\usetikzlibrary{calc,fit}
\makeatletter
\newcommand{\geometrylen}[1]{\csname Gm@#1\endcsname}
\@newtikzpagenode{current page layout area}{%
\def\northeast{%
\pgfpoint{\paperwidth-\geometrylen{layouthoffset}}
{\paperheight-\geometrylen{layoutvoffset}}
}
\def\southwest{%
\pgfpoint{\paperwidth-\geometrylen{layouthoffset}-\geometrylen{layoutwidth}}
{\paperheight-\geometrylen{layoutvoffset}-\geometrylen{layoutheight}}
}%
}
\makeatother

\geometry{twoside=true,landscape,%
layoutwidth=300mm,layoutheight=217mm,layouthoffset=60mm,layoutvoffset=30mm,showcrop,showframe,
bindingoffset=5mm,left=32mm, textwidth=197mm,marginparsep=4mm,marginparwidth=47mm,%
a3paper,}

\begin{document}
\lipsum[1]
\begin{tikzpicture}[remember picture,overlay]
\draw[red] (current page layout area.south west) rectangle (current page layout area.north east);
\end{tikzpicture}
\clearpage
\newgeometry{twoside=true,landscape,%
layoutwidth=300mm,layoutheight=297mm,layouthoffset=60mm,layoutvoffset=0mm,showcrop,showframe,
bindingoffset=5mm,left=32mm, textwidth=197mm,marginparsep=4mm,marginparwidth=47mm,%
a3paper,}
\lipsum[2]
\begin{tikzpicture}[remember picture,overlay]
\draw[red] (current page layout area.south west) rectangle (current page layout area.north east);
\end{tikzpicture}
\end{document}


Perhaps the most straightforward way is to simply redefine the crop marks to be drawn the other direction (i.e., away from the edge). Page 1 below is based on your first MWE, whereas page 2 is based on the second.

\documentclass{book}
\usepackage{lipsum}
\usepackage{geometry}
\usepackage{picture}

\makeatletter
\def\Gm@cropmark(#1,#2,#3,#4){%
\begin{picture}(0,0)
\setlength\unitlength{1truemm}%
\linethickness{0.25pt}%
\put(#3,0){\line(#1,0){17}}%
\put(0,#4){\line(0,#2){0.495\Gm@layoutheight}}%
\end{picture}}%

\renewcommand*{\Gm@pageframes}{%
\vb@xt@\z@{%
\ifGm@showcrop
\vb@xt@\z@{\vskip-1\Gm@truedimen in\vskip\Gm@layoutvoffset%
\hb@xt@\z@{\hskip-1\Gm@truedimen in\hskip\Gm@layouthoffset%
\vb@xt@\Gm@layoutheight{%
\let\protect\relax
\hb@xt@\Gm@layoutwidth{\Gm@cropmark(-1,-1,-3,0)\hfil\Gm@cropmark(1,-1,3,0)}%
\vfil
\hb@xt@\Gm@layoutwidth{\Gm@cropmark(-1,1,-3,0)\hfil\Gm@cropmark(1,1,3,0)}}%
\hss}%
\vss}%
\fi%
\ifGm@showframe
\if@twoside
\ifodd\count\z@
\let\@themargin\oddsidemargin
\else
\let\@themargin\evensidemargin
\fi
\fi
\moveright\@themargin%
\vb@xt@\z@{%
\vskip\topmargin\vb@xt@\z@{\vss\Gm@hrule}%
\@tempdima\textwidth
\if@mparswitch
\ifodd\count\z@
\Gm@vrules@mpi
\else
\Gm@vrules@mpii
\fi \else
\Gm@vrules@mpi
\fi
\vb@xt@\z@{\vss\Gm@hrule}%
\vskip\footskip\vb@xt@\z@{\vss\Gm@hruled}%
\vss}%
\fi%
}}%
\makeatother

\geometry{twoside=true,landscape,%
layoutwidth=300mm,layoutheight=217mm,layouthoffset=60mm,layoutvoffset=30mm,showcrop,showframe,
bindingoffset=5mm,left=32mm, textwidth=197mm,marginparsep=4mm,marginparwidth=47mm,%
a3paper,}

\begin{document}
\lipsum[1]

\newgeometry{twoside=true,landscape,%
layoutwidth=300mm,layoutheight=297mm,layouthoffset=60mm,layoutvoffset=0mm,showcrop,showframe,
bindingoffset=5mm,left=32mm, textwidth=197mm,marginparsep=4mm,marginparwidth=47mm,%

If you do not want to load the picture package, you can hard-code the vertical crop mark length into the picture environment with something like \put(0,#4){\line(0,#2){108}}