Sorry for the vague title, I honestly have no idea what they're called, so it makes googling for them rather hard. (Edit It's apparently called a "thumb index")
I'm looking to do something similar to this:
Where the chapter and section headings that normally occur at the top of the page when using the book documentclass are instead flipped vertically and shoved into the margins as shown in the example picture above.
The colour of the box isn't exactly important and can be tweaked later on, but I do want a box around all three of these regardless.
So, can anybody help me out in figuring this out?