I am trying to get a background rectangle of colour covering one of two columns on a page done with multicol, with the rectangle going right to the edge of the paper.
I am confused about the position= option to the \backgroundsetup command of the background package, as it doesn't appear to bear any relationship to the bottom corner of the page. In the example below, I try to adjust the width of the rectangle to take the margins into account. The vertical position seems to be half-way up the page, despite the y-position being zero. I am clearly misunderstanding something here, but I can't see what.
\PassOptionsToPackage{svgnames}{xcolor}
\documentclass{report}
\usepackage{lipsum,multicol,calc}
\usepackage[a4paper,twoside,
textheight=240mm,footskip=25mm,
inner=20mm,outer=35mm,top=15mm, nohead]{geometry}
\usepackage[pages=some]{background}
\usepackage[svgnames]{xcolor}
\setlength{\columnsep}{10mm}
\AtBeginDocument{%
\raggedright
\parskip=\baselineskip
\parindent=0pt}
\newlength{\bgwidth}% calculated width of rectangle
\newlength{\bgxpos}% calculated location of x-position
\makeatletter
\newcommand{\leftcolbackground}{% try to make it work L and R
\ifodd\c@page
\setlength{\bgxpos}{20mm}%
\setlength{\bgwidth}{\bgxpos + \oddsidemargin}%
\else
\setlength{\bgxpos}{35mm}%
\setlength{\bgwidth}{\bgxpos + \evensidemargin}%
\fi
\addtolength{\bgwidth}{\columnwidth}% assumes we are inside multicols
\typeout{columnwidth=\the\columnwidth, bgxpos=\the\bgxpos,
bgwidth=\the\bgwidth}%
\def\colbg{%
\begin{tikzpicture}
\fill[yellow] (0,0) rectangle (\bgwidth,\paperheight);
\end{tikzpicture}}%
\backgroundsetup{scale=1,color=black,opacity=1,
angle=0,position={\bgxpos,0},contents=\colbg}
\BgThispage}
\makeatother
\listfiles
\begin{document}
\chapter{Introduction}
\begin{multicols}{2}
\lipsum[1]
\lipsum[2]
\lipsum[3]
\lipsum[4]
\lipsum[5]
\lipsum[6]
\lipsum[7]
\lipsum[8]
\lipsum[9]
\lipsum[10]
\leftcolbackground
\section{This is a demo}
\lipsum[11]
\lipsum[12]
\subsection{Increasing the uptake of STEM candidates}
\lipsum[13]
\lipsum[14]
\section{This is another demo}
\lipsum[15]
\lipsum[16]
\lipsum[17]
\lipsum[18]
\subsection{More subtitling}
\lipsum[19]
\lipsum[20]
\lipsum[21]
\lipsum[22]
\end{multicols}
\end{document}
Best Answer
I suggest to start with
or
to get the rectangle into defined position and then shift it with
hshift=...
orvshift=...
, like inHere is the output of these three settings.