Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am using memoir and I have the showtrims setting activated which I want visible on my pages. I am trying to toggle shading of entire pages and so far I am not having any great success. I have looked around but not seen anything obvious that can help me but this is what I have managed to come up with:

\documentclass[showtrims, 10pt]{memoir}
\usepackage{lipsum}
\usepackage{eso-pic}

\stockaiv
\settrims{20mm}{20mm}
\trimFrame

\pagesmallroyalvo

\setbinding{4mm}
\settypeblocksize{*}{24.5pc}{1.618}
\setlrmargins{*}{*}{1.5}
\setulmarginsandblock{6pc}{7pc}{*}
\setmarginnotes{6pt}{6pc}{12pt}
\strictpagecheck
\setlength{\topskip}{1.6\topskip}
\checkandfixthelayout

\begin{document}
\lipsum[1-4]

\newpage
\AddToShipoutPictureBG{
  \AtStockUpperLeft{
    \colorbox{cyan}{\vspace* \stockheight \hspace \stockwidth}
  }
}

\lipsum[1-4]

\AddToShipoutPictureBG{
  \AtStockUpperLeft{
  }
}
\newpage
\lipsum[1-4]


\end{document}

However there are two problems.

  1. I can't seem to manage to fill out the page in the vertical direction. Only in te horizontal.

  2. I don't seem to be able to turn it off by changing the ship out picture again.

What am I doing wrong? Or is there a better way of doing this?

share|improve this question
    
Related question: setting background colour for part of a page –  Peter Grill Nov 28 '11 at 21:15
1  
Possible duplicate: how to change the background color only for the current page –  Peter Grill Nov 28 '11 at 21:15
    
EDIT: I added a little line to the beginning clarifying about the trim marks which are in my example. –  jonalv Nov 29 '11 at 10:21
add comment

4 Answers

up vote 4 down vote accepted

You could use the background package; the \NoBgThispage commands allows you to suppress the color for the pages in which the command is used:

\documentclass[showtrims, 10pt]{memoir}
\usepackage{lipsum}
\usepackage{ifthen,background}

\stockaiv
\settrims{20mm}{20mm}
\trimFrame

\pagesmallroyalvo

\setbinding{4mm}
\settypeblocksize{*}{24.5pc}{1.618}
\setlrmargins{*}{*}{1.5}
\setulmarginsandblock{6pc}{7pc}{*}
\setmarginnotes{6pt}{6pc}{12pt}
\strictpagecheck
\setlength{\topskip}{1.6\topskip}
\checkandfixthelayout

\SetBgScale{1}
\SetBgAngle{0}
\SetBgVshift{10pc}
\SetBgColor{cyan}

\makeatletter
\AddEverypageHook{%
  \ifthenelse{\isodd{\value{page}}}{\SetBgHshift{8pc-1.5pt}}{\SetBgHshift{5pc-3pt}}
  \SetBgContents{\rule{\paperwidth}{\paperheight}}%
  \bg@material
}
\makeatother

\begin{document}

\lipsum[1-4]

\newpage\NoBgThispage
\lipsum[1-4]

\newpage
\lipsum[1-4]

\end{document}

Compile the document twice.

Using the above code, only the actual page will receive a colored background; increasing the width and height of the rule, you can obtain some bleed. Here's the result obtained by replacing \SetBgContents{\rule{\paperwidth}{\paperheight}} with \SetBgContents{\rule{\dimexpr\paperwidth+3cm\relax}{\dimexpr\paperheight+3cm\re‌​lax}} in the code above:

enter image description here enter image description here

share|improve this answer
1  
I didn't know about the background package until reading your solution -- very nice!! –  Mico Nov 28 '11 at 19:21
    
This solution only colors the actual page but I need a bleed. One can not trust the printing process to cut the paper perfect. –  jonalv Nov 29 '11 at 9:31
    
@jonalv Simply increase the width and height of the rule used to place the background, using something like \SetBgContents{\rule{\dimexpr\paperwidth+2cm\relax}{\dimexpr\paperheight+2cm\re‌​lax}}. –  Gonzalo Medina Nov 29 '11 at 13:08
    
@Mico: Thank you. –  Gonzalo Medina Nov 29 '11 at 13:26
    
Very nice, now I just need to figure out how to put this code in an environment so I can do it where I need it and not only for odd pages... –  jonalv Nov 29 '11 at 13:36
show 4 more comments

You can use \pagecolor to specify the background color of the page, and \afterpage from the afterpage package to reset to \nopagecolor after the current page is output.

enter image description here

Known Issues:

  • As noted by @jonalv this solution places itself on top of the frame showing the paper size, so is not a good solution when you require both the frame and page color.

Code:

\documentclass{article}
\usepackage{afterpage}
\usepackage{xcolor}
\usepackage{lipsum}% for dummy text

\begin{document}
\pagecolor{yellow!20}\afterpage{\nopagecolor}
\lipsum[1-11]
\pagecolor{blue!20}\afterpage{\pagecolor{red!20}}
\lipsum[1-10]
\end{document}
share|improve this answer
    
This solution places itself on top of the memoir frame showing the cut paper size. That is not very good... –  jonalv Nov 29 '11 at 9:28
add comment

I changed the colorbox to a \rule and anchored it at the bottom left, instead of the top left.

To clear it from subsequent pages, I used \ClearShipoutPictureBG

screenshot

\documentclass[showtrims, 10pt]{memoir}
\usepackage{lipsum}
\usepackage{eso-pic}

\stockaiv
\settrims{20mm}{20mm}
\trimFrame

\pagesmallroyalvo

\setbinding{4mm}
\settypeblocksize{*}{24.5pc}{1.618}
\setlrmargins{*}{*}{1.5}
\setulmarginsandblock{6pc}{7pc}{*}
\setmarginnotes{6pt}{6pc}{12pt}
\strictpagecheck
\setlength{\topskip}{1.6\topskip}
\checkandfixthelayout

\begin{document}
\lipsum[1-4]

\newpage
\AddToShipoutPictureBG{
  %\AtStockUpperLeft{
  %  \colorbox{cyan}{\vspace* \stockheight \hspace \stockwidth}
  %}
  \AtTextLowerLeft{% put it at the left bottom of the text area
  \color{cyan}\rule{\textwidth}{\LenToUnit\textheight}%
  }%
}

\lipsum[1-4]


\newpage
\lipsum[1-4]
\ClearShipoutPictureBG{}


\end{document}
share|improve this answer
    
With some easy enough modifications (move the color to the stock end and change it to stock size) this solution can be made to cover the entire page so I get the needed bleed. However sadly enough it still covers the memoir page cutting frame. :( –  jonalv Nov 29 '11 at 9:36
add comment

Based on cmhughes answer I came up with this solution which has all the signs of an ugly hack:

\documentclass[showtrims, 10pt]{memoir}
\usepackage{lipsum}
\usepackage{eso-pic}
\usepackage{transparent}

\stockaiv
\settrims{20mm}{20mm}
\trimFrame

\pagesmallroyalvo

\setbinding{4mm}
\settypeblocksize{*}{24.5pc}{1.618}
\setlrmargins{*}{*}{1.5}
\setulmarginsandblock{6pc}{7pc}{*}
\setmarginnotes{6pt}{6pc}{12pt}
\strictpagecheck
\setlength{\topskip}{1.6\topskip}
\checkandfixthelayout

\begin{document}
\lipsum[1-4]

\newpage
\AddToShipoutPictureBG{
  %\AtStockUpperLeft{
  %  \colorbox{cyan}{\vspace* \stockheight \hspace \stockwidth}
  %}
  \AtStockLowerLeft{% put it at the left bottom of the text area
  \color{cyan}\transparent{0.5}\rule{\stockwidth}{\LenToUnit\stockheight}%
  }%
}

\lipsum[1-4]


\newpage
\lipsum[1-4]
\ClearShipoutPictureBG{}


\end{document}

This solution has the disadvantage that the actual color needs to be calculated by taking the transparency into account so it's not the ideal solution...

enter image description here

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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