[Tex/LaTex] How to split latex page horizontally, and have a different colour background to the two halves

minipagetikz-styles

I am writing a book and would like each page to be cut in half with red at the top and blue at the bottom (not including front page of initial front book matter). and then add separate text to each of the half of the page (was thinking minipage might be able to do this? – imagine bad advice top half and good advice bottom half of the page. Is this possible?

Best Answer

You could use eso-pic.

The following assumes, that the half of the text field is at the same height as the half of the paper. This is not necessarily true (and is false for default book page layout, roughly half of the last line of the first half of the text field lies in the second half of the page).

We first define an environment (advisepage in the following) for a coloured page. This environment does only colour a single page (top half red, bottom half blue). In this environment we use another environment (advise in the following) that is essentially just a minipage of fixed height .5\textheight and width \textwidth.

Code:

\documentclass[]{book}

\usepackage{xcolor}
\usepackage{environ}
\usepackage{eso-pic}

\makeatletter
\colorlet{goodadviseblue}{blue!25}
\colorlet{badadvisered}{red!25}
\newenvironment{advisepage}
  {%
    \clearpage
    \AddToShipoutPictureBG*
      {%
        \AtPageUpperLeft
          {%
            \color{badadvisered}%
            \raisebox{-.5\paperheight}{\rule{\paperwidth}{.5\paperheight}}%
          }%
        \color{goodadviseblue}%
        \rule{\paperwidth}{.5\paperheight}%
      }%
  }
  {%
    \clearpage
  }
\newenvironment{advise}
  {%
    \noindent
    \begin{minipage}[t][.5\textheight]{\textwidth}
  }
  {%
    \end{minipage}%
  }
\usepackage{duckuments}
%\expandafter\show\csname set@page@color\endcsname

\begin{document}
\begin{advisepage}
  \begin{advise}
    This is my bad advise
  \end{advise}
  \begin{advise}
    This is my good advise
  \end{advise}
\end{advisepage}
Another page
\end{document}

enter image description here