in the code given below for placing a chapter thumb, I wanted to modify the simple rectangular box to give this as the new chapter thumb:

enter image description here

Here is the code that I have so far:


\usepackage{atveryend}%%%% <--- !





\usetikzlibrary{tikzmark,calc,arrows,shapes,decorations.pathreplacing,pgfplots.groupplots, matrix}
\tikzset{every picture/.style={remember picture}}

% auxiliary counter

% the list of colors to be used (add more if needed)
  %\ifcase\thechapshift blue!30\or red!30\or olive!30\or magenta!30\else yellow!30\fi}

\begin{tikzpicture}[overlay, remember picture]%
    \fill[fillh] (current page.north west) rectangle ($(current page.north east)+(0,-\hdheight)$);
    \draw[line] ([yshift=-\hdheight]current page.north west) -- ([yshift=-\hdheight]current page.north east);
    \node[anchor=south west, font=\sffamily, text width=1cm] (evenpagenum) at ($(current page.north west)+(.5\hdheight,-\hdheight)$) {\thepage};
    \node[anchor=south west, text width=1.5cm, text=white, font=\fontsize{2cm}{5.5cm}\selectfont] (chapter) at (evenpagenum.south east) {\thechapter};
    \node[anchor=south west] at (chapter.south east) {\leftmark};
    \node[fill=\BoxColor,inner sep=0pt,rectangle,text width=1cm,
    text height=4cm,align=center,anchor=north east]
  at ($ (current page.north east) + (-0cm,-2*\thechapshift cm) $)
   \centering\textcolor{white}{\bfseries\scshape\rightmark \\ \sffamily\subsectiontitle}}}};

\begin{tikzpicture}[overlay, remember picture]%
    \fill[fillh] (current page.north west) rectangle ($(current page.north east)+(0,-\hdheight)$);
    \draw[line] ([yshift=-\hdheight]current page.north west) -- ([yshift=-\hdheight]current page.north east);
    \node[align=right, anchor=south east, font=\sffamily, text width=1cm] (evenpagenum) at ($(current page.north east)+(-.5\hdheight,-\hdheight)$) {\thepage};
    \node[align=right, anchor=south east, text width=1.5cm, text=white, font=\fontsize{2cm}{5.5cm}\selectfont] (chapter) at (evenpagenum.south west) {\thechapter};
    \node[align=right, anchor=south east] at (chapter.south west) {\leftmark};
      \node[fill=\BoxColor,inner sep=0pt,rectangle,text width=1cm,
    text height=4cm,align=center,anchor=north west]
  at ($ (current page.north west) + (-0cm,-2*\thechapshift cm) $)
    \centering\textcolor{white}{\bfseries\scshape\rightmark \\ \sffamily\subsectiontitle}}}};

\usepackage[height={2cm},distance={2mm},topthumbmargin={auto},bottomthumbmargin={auto}]{thumbs}%%%% <--- !

\pagenumbering{arabic}%%%% <--- !
\addthumb{\thechapter}{\Large{\thechapter}}{white}{mybluei}%%%% <--- !
\section{Problem 1}
\subsection{Problem 1}
\subsection{Solution 1}

\chapter{Appendix \thechapter}
\addthumb{\thechapter}{\Large{\thechapter}}{white}{mybluei}%%%% <--- !


Here is a solution (edited) using the thumbs package, as requested in the comments. I removed my old solution because I think the advanced behaviour of the thumbs package is essentially always preferable.

Apologies I started from scratch as I wasn't sure what all in your MWE was actually needed.


  • To obtain the graphic, we overwrite the \rule within \th@mbprint command using \patchcmd from etoolbox
  • We use the length \th@mbposyA from thumbs package and \paperheight to determine the length of the lines
  • We append to \chaptermark to store the chapter title in \chap@title, which we then rotate in a protected group \chaptitle
  • We also use \apptocmd from etoolbox to call \addthumb after every \chapter


\usepackage[a6paper]{geometry} % demo only
\usepackage{lipsum}            % demo only
% <solution>
\usepackage[width=1cm,height=3cm,distance=2mm]{thumbs} % for thumbs
\usepackage{etoolbox}   % fot patching
\usepackage{tikz}       % for drawing
\usetikzlibrary{arrows} % for "-o"
%  \rule{#1}{#2} % DEBUG: original thumbs behaviour
  \ifodd\c@CurrentPage\def\sign{+}\else\def\sign{-}\fi % flip stuff
    \useasboundingbox (0,0) rectangle ++ (#1,#2); % same placement
    \fill[\th@mbbackgroundcolourA] % color block
         (#1,#2) rectangle
         (0,0) --
      ++ (+0.5#1,-0.5#1) --
      ++ (+0.5#1,+0.5#1);
    \draw[\th@mbbackgroundcolourA,ultra thick,-o] % middle line
         (0.5#1,#2) --
      ++ (0,\th@mbposyA-#2-\paperheight+2#1) --
      ++ (\sign1.5#1,-1.5#1);
    \draw[\th@mbbackgroundcolourA,ultra thick,-o] % inner line
         (0.5#1\sign0.5#1,#2) --
      ++ (0,\th@mbposyA-#2-\paperheight+2.212#1) --
      ++ (\sign1.0#1,-1.0#1);
%    \draw[red,dashed] (0,0) rectangle (#1,#2); % DEBUG: same as original
\patchcmd{\th@mbprint}{\rule}{\fancyrule}{}{} % patch the "rule"
\newcommand{\chaptitle}{% for rotating the thumbs content
\let\ochaptermark\chaptermark % for storing the chapter title
\apptocmd{\@chapter}{% add thumb after every chapter command
  \addthumb{\thechapter}{\sffamily \protect\chaptitle}{white}{mybluei}
% </solution>
  \section{Hard Ones}


(a6paper is very small so we can see multiple pages)

enter image description here

  • 1
    But your code doesn't shift the thumbs at the beginning of each new chapter. Isn't this the actual intention of thumbs? Not to mention the case when the thumbs reach the bottom of the page and have to jump to the top again. All those cases are handled by thumbs.sty. Oct 21 '20 at 14:53
  • 1
    Fair point. I missed the thumbs package loading here. It's possible to move the thumbs down incrementally in my solution using \thechapter and yshift, but a) it won't wrap, and b) it breaks after \appendix since \thechapter becomes a letter. I wasn't 100% clear what the OP was asking TBH. Oct 21 '20 at 15:22
  • 1
    It seems the thumbs package only supports rectangular blocks. Let me look at the implementation to see if there's a hook we can use. Oct 21 '20 at 22:54
  • 1
    @jessexknight A hook could be \th@mbprint. But expansion is so weird there that this is no fun... Oct 21 '20 at 23:16
  • 1
    @Joe Please see the revised solution which uses the thumbs package now. Thanks for your input Andreas! Oct 22 '20 at 23:45

Here is an extended version that shifts and wraps around. It's based on the example of @jessexknight.


\newlength\ctw % half width
\newlength\cth % height
\newlength\ctx % x-offset
\newlength\cttopmargin % top margin of first thumb
\newlength\ct@top % current top

  \def\my@thumb{\sffamily\normalsize\bfseries #1}%
  \addtolength\ct@top{\cth}% old \cth
  \settowidth\cth{\my@thumb}% new \cth
  \addtolength\cth{20pt}% label margin
  \ifdim \dimexpr\ct@top+\cth\relax > \dimexpr\paperheight-6\ctw\relax


        \ct@top@ = \ct@top / -1cm;
        \ct@ht = \cth / 1cm;
        \ct@label = \ct@top@ - \ct@ht / 2;
      \fill[thumb] (0,\ct@top@) rectangle
            ++ (-2\ctf,-1\cth)
         -- ++ (+1\ctf,-1\ctw)
         -- ++ (+1\ctf,+1\ctw);
      \draw[thumb,ultra thick,-o] (-1\ctf,\ct@top@)
         -- (-1\ctf,-\paperheight+4\ctw)
         -- ++ (-3\ctf,-3\ctw);
      \draw[thumb,ultra thick,-o] (-2\ctf,\ct@top@)
         -- (-2\ctf,-\paperheight+4.414\ctw)
         -- ++ (-2\ctf,-2\ctw);
      \node[white] at (-\ctf,\ct@label) {\rotatebox{90}{\my@thumb}};

% user interface
\setlength\ctw{0.2in}% half width of thumb
\setlength\cttopmargin{20mm}% top margin of first thumb
\definecolor{thumb}{RGB}{0,173,239}% color of thumb

% set thumb with: \thumb{foobar}
% stop thumbs with: \nothumbs

\chapter{No thumbs here}\lipsum[1-6]
\chapter{XXX 1}\thumb{Lorem ipsum}\lipsum[1-6]
\chapter{XXX 2}\thumb{Dolor}\lipsum[1-6]
\chapter{XXX 3}\thumb{Sit a met consectetuer}\lipsum[1-6]
\chapter{XXX 4}\thumb{Adipiscing elit}\lipsum[1-6]
\chapter{XXX 5}\thumb{Ut purus elit vestibulum ut}\lipsum[1-6]
\chapter{XXX 6}\thumb{Nunc eleifend consequat lorem}\lipsum[1-6]
\chapter{XXX 7}\thumb{Molestie vitae placerat}\lipsum[1-6]
\chapter{XXX 8}\thumb{Tortor gravida sapien}\lipsum[1-6]
\chapter{AAA 1}\thumb{Phasellus eu tellu}\lipsum[1-6]
\chapter{AAA 2}\thumb{Praesent eget sem vel leo}\lipsum[1-6]
\chapter{Again no thumbs}\nothumbs\lipsum[1-6]

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.