2

With \pagecolor you can change the colour of the entire page. However I'm trying to create a style which has a fixed-width white band at the top of the page and a solid fill colour for the rest of the paper. The colour should extend margin to margin.

I've been trying to achieve this using \colorbox around a minipage environment but am having trouble getting the minipage to automatically resize vertically.

Here's a MWE and example:

\documentclass[a4paper]{article}

\usepackage[margin=1in,top=2in]{geometry}
\usepackage{xcolor}
\usepackage{framed}

\begin{document}

\pagestyle{empty}

% move box to leftmost edge of paper
\noindent\hspace*{-1in}%
\colorbox{red}{\begin{minipage}{\paperwidth}%
    % Start text back at original margin
    \hspace*{1in}
    \color{white}
    \Huge Hello!

    % Fill to bottom of page? Not working
    \vspace*{\fill}\mbox{}
  \end{minipage}
}

\end{document}

Red fill should go all the way to bottom of page

1

The following examples uses eso-pic to insert a red block in the BackGround of every page. The red block spans the width of the entire page horizontally, and covers everything but the top 2in vertically:

enter image description here

\documentclass{article}

\usepackage[margin=1in,top=2in]{geometry}
\usepackage{xcolor,eso-pic}

\AddToShipoutPictureBG{
  \AtPageLowerLeft{%
    \color{red}%
    \rule{\pdfpagewidth}{\dimexpr\pdfpageheight-2in}%
  }
}

\pagestyle{empty}

\begin{document}

\color{white}% Set text colour
\Huge\bfseries Hello!

\end{document}
1
  • I didn't say but I needed this for the first page only; easily achieved with \AddToShipoutPictureBG*{...}. Thanks for pointing me in the right direction.
    – jkeirstead
    Dec 23 '16 at 7:56
2

Here's a solution using TikZ.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}

\pagestyle{empty}
\begin{document}
\begin{tikzpicture}[remember picture,overlay]
  \fill[red] ($(current page.north west)-(0cm,3cm)$) rectangle (current page.south east);
\end{tikzpicture}

\color{white}\Huge\bfseries Hello!
\end{document}

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.