I know that this should be possible, but I'm not sure how to go about it.

I would like to have a small rectangle appear on each page (outside edge), which runs right up to the edge of the page, and for it to be in the same place for each page - so that when the book is printed, the colour is visible on the outside edge of the page.

My current thinking is that i could maybe include something in my fancychap which did it for me, but I really don't know a huge amount about latex, so where to go from here has me a little lost...

Doing somthing like this gets be someway there:

%................"Fancy Headers" - Nice page headings
\renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}}

\fancyhead[LE]{\colorbox{cyan}{\parbox[l][10mm][c]{10mm}{\hspace*{50pt}}} \thepage}
\fancyhead[RO]{\thepage \colorbox{cyan}{\parbox[l][10mm][c]{10mm}{\hspace*{50pt}}}}

\fancyhead{} % get rid of headers
\renewcommand{\headrulewidth}{0pt} % and the line

But all that does is put the colorbox in the corner, outside of the page number. I'd rather it was a few inches down the page (i.e. outside of the header).

This gives this: enter image description here

which isn't all the way there. The last time i tried something like this it took me hours, and this is a little worse than the previous thing i tried. Can any of you think of a simple(ish) way i could go about this?

I already have this for my titles:


%.................Custom chapter headings

{\chapter} % command
[display] % shape
{\fontsize{76}{80}\usefont{OT1}{pzc}{m}{n}\selectfont}% format
\ifodd \c@page \raggedleft \else \raggedright \fi \colorbox{cyan}{\parbox[l][25mm][c]{100mm}{\ifodd \c@page \raggedleft \thechapter \hspace*{20mm} \else \raggedright \hspace*{20mm} \thechapter \fi}}% title code
}% label
{-136pt}% sep
{\bfseries\Huge \ifodd \c@page \raggedleft \else \raggedright \fi%
\ifodd \c@page \raggedleft \else \raggedright \fi  \colorbox{cyan}{\parbox[l][15mm][c]{100mm}{\ifodd \c@page \hspace*{7mm} \raggedright #1 \else \raggedleft #1 \hspace*{7mm} \fi}}%



which places coloured boxes around the titles and their numbers which extend off the edge of the page. Ideally, the swatches on the other pages would line up with these ones. The bonus of using the header to do it would be that you wouldn't have to add in any special logic to deal with the pages that don't have headers (like the title page, contents, and other pages where the chapter starts and stuff).


2 Answers 2


Here is another suggestion using scrlayer-scrpage for the header.


\renewcommand\chaptermarkformat{}% no chapternumber in header

% define new layers
  voffset=0pt,%distance from top
  width=1cm,% width of the swatch
  height=\dimexpr\voffset+1in+\topmargin+\headheight\relax,% height of the swatch

% add layers to every pagestyle


\chapter{First chapter}\swatchcolor{orange}
\section{First section}
\chapter{Second chapter}\swatchcolor{purple}
\section{First section}
\chapter{Third chapter}\swatchcolor{blue!80!black}
\section{First section}

enter image description here

It works also if you use an oneside layout. Then the swatch is on every page at the right (=outer) margin automatically.


enter image description here


This uses \atxy{This page x}{alt page x}{y}{content} to place something at alternating locations on even/odd pages, and \updateText{content} to change the content. In this case, my content is a .5in x .5in colored box, which I change part-way through the document.

Because my paper is 8.5 in wide, my this page x is 8in, while my alt page x is 0 in (for a 1/2 in box). Likewise, the y value is .5 in.

% SYNTAX \atxy{This page X}{Alt page X}{y}{content}

enter image description here

My answer was based on my answer at How can (easily) superimpose different text over odd/even pages of an included PDF file?, except in that case, the content was text, not a color swatch.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .