2

Thanks to several helpful people in an earlier question ("Create a TikZ overlay with RH mirror of LH") I managed to get my pattern background where it was needed. Now circumstances have changed, and it is needed for the cover for documents of varying thickness (so the width will be, for example, 5mm greater than standard paper width). The background pattern need to bleed 3mm off the edge on all four sides, fo trimming.

The test below uses the code from the earlier question, with the \bgmaster pattern 3mm wider on all edges (see image). The page background is formed from the RH half of the image placed on the LH half of the page, and the same RH half of the image mirror-flipped and placed on the RH half of the page. I can't see how to move the patterns up and right so that they properly overlap the crop marks by 3mm.

\documentclass[10pt,oneside]{report}
% Draw-on cover for A4 booklet 5mm thick, so basically A3
% A3 + 5mm more width to allow for thickness of spine.
% 3mm oversize is needed  on all sides to allow for bleed.
% Printed on SRA3 which is 320mm × 450mm
\usepackage[landscape,papersize={297mm,425mm},
  left=30mm,right=25mm,top=20mm,bottom=5mm,
  nohead,nofoot]{geometry}
% left side is the back cover, right side is the front cover
\usepackage[cam,center,width=450mm,height=320mm,landscape]{crop}
\usepackage[svgnames]{xcolor}
\usepackage{tikz}
% Create a diagonal-shaded pattern 
\newsavebox{\bgmaster}
% Make height and width 6mm more than paper size
\newlength{\overwidth}
\setlength{\overwidth}{\paperwidth}
\addtolength{\overwidth}{6mm}
\newlength{\overheight}
\setlength{\overheight}{\paperheight}
\addtolength{\overheight}{6mm}
% Pattern taken from another document
\savebox{\bgmaster}{%
  \begin{minipage}{\overwidth}%
    \begin{tikzpicture}%
      \node [shading = axis,
        rectangle,
        left color=CornflowerBlue,
        right color=CornflowerBlue,
        middle color=Orchid,
        shading angle=45,
        minimum width=\overwidth,
        minimum height=\overheight]{};
    \end{tikzpicture}%
  \end{minipage}%
}
\parindent0pt
\parskip0pt
\pagestyle{empty}
\begin{document}
% Use the RH half of the shaded pattern for the LH side
\begin{tikzpicture}[overlay,remember picture]
  \clip (current page.south west)
   rectangle (current page.north east);
   \node at (current page.west) {\usebox{\bgmaster}};
\end{tikzpicture}
% Use the RH half but mirror-flipped for the RH side
\begin{tikzpicture}[overlay,remember picture]
  \clip (current page.south west)
        rectangle (current page.north east);
  \node at (current page.east)
      {\reflectbox{\rotatebox[origin=c]{180}%
        {\usebox{\bgmaster}}}};
\end{tikzpicture}%
\end{document}

This is largely because I don't grok the fullness of \clip in TikZ yet. It's unclear to me what it is clipping: (a) the undimensioned tikzpicture, (b) the box being included by the \node statement, (c) the current logical LaTeX page, or (d) the papersheet on which LaTeX will put the current page. And it appears that \clip doesn't actually clip in the normal sense of crop, but imposes some kind of path on something. Does anyone have a suggestion as to how I can push the patterns up and right?

Page image of test file above

  • Simply remove both \clip – Symbol 1 Apr 9 '17 at 23:04
  • Since you are doing both halves on a single page, you don't need to split them in two. Just place the oversized image at '(current page.center)` using overlay. – John Kormylo Apr 10 '17 at 2:25
  • But this page needs to use only the right-hand half of the pattern: once on the LH side, and once (mirrored) on the RH side, to make it symmetrical. The full image is a wide assymetrical diagonal pattern of which my user only wants to use the right-hand half. (The whole image does get used elsewhere in another of his documents, which is why I simply copied the definition in its entirety). – Peter Flynn Apr 10 '17 at 20:52
  • Removing the \clip commands certainly moves the pattern up, but it is now bleeding off both left and right edges. I need it to extend only 3mm outsize the boundary imposed by the cropmarks. How do I restrict (crop? clip? trim?) the node containing the pattern box \node at (current page.west) {\usebox{\bgmaster}} to stop it running off the edge at the left (and mutatis mutandis for the other one to the right)? – Peter Flynn Apr 10 '17 at 21:41
1

The clip rectangle limits the area painted by the image. It was originally intended just to split the image into two halves for odd and even pages, but in this case only the right half image is used (twice).

Using the calc tikzlibrary one can offset the corners of the clip rectangles by 3mm in x and/or y.

\documentclass[10pt,oneside]{report}
% Draw-on cover for A4 booklet 5mm thick, so basically A3
% A3 + 5mm more width to allow for thickness of spine.
% 3mm oversize is needed  on all sides to allow for bleed.
% Printed on SRA3 which is 320mm × 450mm
\usepackage[landscape,papersize={297mm,425mm},
  left=30mm,right=25mm,top=20mm,bottom=5mm,
  nohead,nofoot]{geometry}
% left side is the back cover, right side is the front cover
\usepackage[cam,center,width=450mm,height=320mm,landscape]{crop}
\usepackage[svgnames]{xcolor}
\usepackage{tikz}
\usetikzlibrary{calc}
% Create a diagonal-shaded pattern 
\newsavebox{\bgmaster}
% Make height and width 6mm more than paper size
\newlength{\overwidth}
\setlength{\overwidth}{\paperwidth}
\addtolength{\overwidth}{6mm}
\newlength{\overheight}
\setlength{\overheight}{\paperheight}
\addtolength{\overheight}{6mm}
% Pattern taken from another document
\savebox{\bgmaster}{%
    \begin{tikzpicture}%
      \node [shading = axis,
        rectangle,
        left color=CornflowerBlue,
        right color=CornflowerBlue,
        middle color=Orchid,
        shading angle=45,
        minimum width=\overwidth,
        minimum height=\overheight]{};
    \end{tikzpicture}%
}
\parindent0pt
\parskip0pt
\pagestyle{empty}
\begin{document}
% Use the RH half of the shaded pattern for the LH side
\begin{tikzpicture}[overlay,remember picture]
  \begin{scope}
    \clip ($(current page.south west)+(-3mm,-3mm)$) rectangle ($(current page.north)+(0pmm,3mm)$);
    \node at (current page.west) {\usebox{\bgmaster}};
  \end{scope}
  \begin{scope}
    \clip ($(current page.south)+(0mm,-3mm)$) rectangle ($(current page.north east)+(3mm,3mm)$);
    \node[xscale=-1] at (current page.east) {\usebox{\bgmaster}};
  \end{scope}
\end{tikzpicture}

\end{document}

demo

  • No, unfortunately that's precisely what he doesn't want. The output needs to be symmetrical, like the example image. – Peter Flynn Apr 10 '17 at 20:53
  • @PeterFlynn - Sigh, it was so much simpler that way. – John Kormylo Apr 11 '17 at 3:42
  • That is wonderful, many thanks. I wasn't aware of the syntax $(current page.south west)+(-3mm,-3mm)$. When you say "The clip rectangle limits the area painted by the image", that's what I understood, but with reference to what? – Peter Flynn Apr 15 '17 at 19:32
  • To be more specific, what is "current page" in this context: the sheet on which everything is printed? the type area defined by the \textheight and \textwidth? the logical area defined by the \bgmaster (in my example)? or the logical area defined by the tikzpicture? In the case of the last two, can I retrieve (via some function?) from tikz the actual (x,y) coordinates that current page.north west evaluates to, for example? I have great difficulty understanding where these locations are on the page. – Peter Flynn Apr 15 '17 at 19:32
  • {current page) is a rectangle \paperwidth by \paperheight, but obviously the crop package sets \pdfpagewidth and \pdfpageheight larger. If you load the tikzpagenodes package it will also define (current page text area) and other nodes for the header, footer and marginpar. – John Kormylo Apr 15 '17 at 19:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.