# Coloured sidenote area for Tufte book

I'm trying to have the sidenote (or margin) area of the tufte-book document class have some background colour. Ideally it would cover the whole page, but only those where it is relevant. I have tried several solutions including: How to set colored ruled margins for different pages? and How to set a certain color (other than white) to margin areas? however none of them really work. I get background colours, but at random places, and it does not really account for which pages have sidenote areas or not (granted I could do it by hand in the worst case, but I'm not even there).

For instance once thing I try it that:

% !TEX program = xelatex

\documentclass{tufte-book}

\usepackage{geometry}
\usepackage{eso-pic,xcolor,lipsum}
\pagecolor{red}
\AtTextLowerLeft{\color{white}%
\rule[-\footskip]{\textwidth}{\dimexpr\textheight+\footskip}}}

\title{Book title that is long}
\author{Some Auhor}

\begin{document}
\maketitle

Test with some notes\sidenote{Test}.

\lipsum
\end{document}


But the background is not limited to the sidenote area.

I would be after something like this: https://www.principiae.be/book/pdfs/TM&Th-samplepages.pdf.

Is there no hope but to find by hand the right dimensions?

• Also: tufte-book is notoriously hard to modify, take a look at kaobook instead... – DG' Mar 4 at 15:57
• Thanks, I'll have a look. – Théo Winterhalter Mar 4 at 16:06
• Just a general observation: If you want to get it right, use your own setup. Take (standard) classes and packages and configure them yourself. You won't run into problems created by the choices and preferences of others. You will run into problems though, but at least they will be your own... – DG' Mar 5 at 22:33
• You mean editing the sources of them right? I followed you advice and switched to kaobook and will modify it if needed. – Théo Winterhalter Mar 6 at 9:27

You need calc to get the lengths right.

\documentclass[nobib]{tufte-book}

\usepackage{xcolor}
\usepackage{eso-pic,picture}
\usepackage{lipsum}
\usepackage{calc}

\newlength{\marginoffset}
\setlength{\marginoffset}{\hoffset+1in+\oddsidemargin+\textwidth+(\marginparsep/2)}

\AtPageLowerLeft{%
\put(\marginoffset,0){%
\color{lightgray}\rule{\paperwidth-\marginoffset}{\paperheight}%
}%
}%
}%

\title{Book title that is long}
\author{Some Auhor}

\begin{document}
\maketitle

Test with some notes\sidenote{Test}.

\lipsum
\end{document}


• This kind of works, but if you want a complex layout and grid typesetting, try ConTeXt – DG' Mar 5 at 22:41