Have minipage take up entire page height

The problem is caused by the \topskip glue, \fboxsep and \fboxrule parameters. Here is an example that works, with exaggerated \fboxsep and \fboxrule values for illustration purposes:

\documentclass[10pt]{article}
\usepackage{xcolor}
\usepackage{calc}
\usepackage[landscape]{geometry}

\geometry{top=0cm, bottom=0cm, left=0cm, right=0cm}

\definecolor{sidebar}{RGB}{71,62,136}

\setlength{\parindent}{0pt}
\setlength{\fboxsep}{10pt}
\setlength{\fboxrule}{20pt}

\begin{document}
\setlength{\topskip}{0pt}

\fcolorbox{black}{sidebar}%
{%
    \begin{minipage}[t][\textheight-2\fboxsep-2\fboxrule][t]{0.2\textwidth}
    \color{white} % White text
    \LARGE Hello

    \end{minipage}%
}

\end{document}

Screenshot

The gray color in this screenshot is from the ”behind-page background” displayed by my PDF viewer; it doesn't belong to the page but shows that the \fcolorbox completely fills the page.

Here is a similar example with normal \fboxsep and \fboxrule values, and two identical pages in order to illustrate how to set and restore \topskip to its default value (see below):

\documentclass[10pt]{article}
\usepackage{xcolor}
\usepackage{calc}
\usepackage[landscape]{geometry}

\geometry{top=0cm, bottom=0cm, left=0cm, right=0cm}

\definecolor{sidebar}{RGB}{71,62,136}

\setlength{\parindent}{0pt}

\begin{document}
%\bgroup
\setlength{\topskip}{0pt}

\fcolorbox{sidebar}{sidebar}%
{%
    \begin{minipage}[t][\textheight-2\fboxsep-2\fboxrule][t]{0.2\textwidth}
    \color{white} % White text
    \LARGE Hello

    \end{minipage}%
}
\newpage
%\egroup

\fcolorbox{sidebar}{sidebar}%
{%
    \begin{minipage}[t][\textheight-2\fboxsep-2\fboxrule][t]{0.2\textwidth}
    \color{white} % White text
    \LARGE Hello

    \end{minipage}%
}
\end{document}

Uncomment the \bgroup and \egroup calls to restore \topskip to its normal value after the first page has been shipped out; then you'll see

Overfull \vbox (1.6pt too high) has occurred while \output is active [2]

for the second page, as expected. The following screenshot was taken in this situation; the first page has \topskip=0pt, while on the second page, it has its default value of 10pt (which can be seen with \showthe\topskip after the uncommented \egroup command):

Screenshot

Notes:

  • \topskip is glue added between the top of the page (according to the margins) and the baseline of first box on a page. The height of the first box is withdrawn from \topskip to compute the glue automatically inserted by TeX; moreover, the inserted glue is set to zero in case the result would be negative—i.e., when the first box is higher than \topskip.

  • Your example is missing xcolor.


If you are OK with loading tikz you could do

\documentclass[10pt]{article}
\usepackage{tikz}
%\usepackage{showframe}
\usepackage[landscape]{geometry}

%\geometry{top=0cm, bottom=0cm, left=0cm, right=0cm}

\definecolor{sidebar}{RGB}{71,62,136}

\begin{document}
\begin{tikzpicture}[overlay,remember picture]
\fill[sidebar] (current page.north west) rectangle 
([xshift=0.2\paperwidth]current page.south west);
\node[anchor=north west,text=white,font=\LARGE] at (current page.north west)  
{Hello};
\end{tikzpicture}
\end{document}

enter image description here


In my opinion the best way to compose such boxes is to use the package textpos. It is tailor made for this purpose, and does not interfere with other material on the page, and you can have normal margin for the rest of the text. If you want the box on every page, you place the textbox in the header by redefining the page style.

So easy:

\documentclass[a4paper, 10pt]{article}

\usepackage{showframe}
\usepackage[landscape]{geometry}
\usepackage{xcolor}
\usepackage[absolute]{textpos}
\setlength{\TPHorizModule}{\paperwidth}
\setlength{\TPVertModule}{\paperheight}
\TPGrid[0mm,0mm]{10}{10}                        % Divide page in 10x10 grid 

\geometry{left=6.5cm}                           % with textpos you can have normal margins

\definecolor{sidebar}{RGB}{71,62,136}
\textblockcolour{sidebar}
\begin{document}

\begin{textblock}{2}(0,0)                       % Box is 0.2 paperheight place in upper left corner
\rule{0pt}{\paperheight}                        % Zero width rule to show the box
\end{textblock}

\end{document}

NB! The gray border is the background, not a border around the page

enter image description here

Tags:

Minipage