I want thumbs
to appear on the right of odd pages and on the left side of even pages. I previously used an old solution
that worked quite well but I did not like the distribution of the thumbs
:
%%% OLD SOLUTION.
\usepackage[height={2cm},distance={5mm},topthumbmargin={auto},bottomthumbmargin={auto}]{thumbs}
\newcommand{\thumbforchapter}{\addthumb{Chapter \thechapter}{\Large{\thechapter}}{white}{gray}}
%%%
I decided to try a new solution
with an even distribution of the thumbs
that also uses all of the space. I managed to do so using tikz
and by tweaking the paperthumb
command found here:
%%% NEW SOLUTION.
%% Specify number of papers
\newcommand{\numberofpapers}[1]{ \setcounter{totpapernum}{#1} }
%% Thumb index to separate papers
\newcommand{\paperthumb}
{
\ifnum \value{thumbpos} = \value{totpapernum}
\setcounter{thumbpos}{0}
\fi
\stepcounter{thumbnum}
\stepcounter{thumbpos}
\pgfmathsetlength{\thumbheight}{\paperheight / \value{totpapernum}}
\begin{tikzpicture}[remember picture, overlay]
\node [thumb, align = right, anchor = north east]
at
($(current page.north east) - (0,{(\value{thumbpos}-1)*\thumbheight})$)
{\thechapter};
\end{tikzpicture}
}
\newcounter{thumbnum}
\newcounter{thumbpos}
\newcounter{totpapernum}
\setcounter{totpapernum}{2}
\newlength{\thumbwidth}
\newlength{\thumbheight}
\setlength{\thumbwidth}{0.4cm}
\tikzset
{
thumb/.style =
{
fill = gray,
text = white,
font = \bfseries\Huge,
text width = \thumbwidth,
minimum height = \thumbheight,
outer sep = 0pt,
inner xsep = 1.5em
}
}
%%%
However, this solution was made to only occur on the chapter title page. I want them to occur on all chapter pages. Also, the new solution is unable to center A
and B
(for Appendix A and B). I tried to do something similar to this answer but it does not work as I intended:
%%% NEW SOLUTION (2).
%% Specify number of papers
\newcommand{\numberofpapers}[1]{ \setcounter{totpapernum}{#1} }
%% Thumb index to separate papers
\newcommand{\paperthumb}
{
\AddEverypageHook{%
\ifodd\value{page}
\backgroundsetup{contents={%
\ifnum \value{thumbpos} = \value{totpapernum}
\setcounter{thumbpos}{0}
\fi
\stepcounter{thumbnum}
\stepcounter{thumbpos}
\pgfmathsetlength{\thumbheight}{\paperheight / \value{totpapernum}}
\begin{tikzpicture}[remember picture, overlay]
\node [thumb, align = right, anchor = north east]
at
($(current page.north east) - (0,{(\value{thumbpos}-1)*\thumbheight})$)
{\thechapter};
\end{tikzpicture}
}
}
}
\else
\backgroundsetup{contents={%
\ifnum \value{thumbpos} = \value{totpapernum}
\setcounter{thumbpos}{0}
\fi
\stepcounter{thumbnum}
\stepcounter{thumbpos}
\pgfmathsetlength{\thumbheight}{\paperheight / \value{totpapernum}}
\begin{tikzpicture}[remember picture, overlay]
\node [thumb, align = right, anchor = north east]
at
($(current page.north east) - (0,{(\value{thumbpos}-1)*\thumbheight})$)
{\thechapter};
\end{tikzpicture}
}
}
\fi
}
Here, the thumbs
appear twice on the right side of the chapter title page but not on the subsequent chapter pages.
- How do I make sure that the
thumbs
on all chapter pages (right side on odd pages and left side on even pages) and not only on the chapter title page? - How do I center the letters (
A
andB
) within the thumbs for the appendices?
Below is an MWE that I created from a huge document, so I apologize if there is something missing. I tried to make it as minimalistic as possible but still have the correct number of chapters and appendices.
\documentclass[pdftex,10pt,b5paper,twoside]{book}
\usepackage[lmargin=25mm,rmargin=25mm,tmargin=27mm,bmargin=30mm]{geometry}
\usepackage[english]{babel}
\usepackage{csquotes}
\usepackage{quotchap}
\usepackage[height={2cm},distance={5mm},topthumbmargin={auto},bottomthumbmargin={auto}]{thumbs}
\usepackage{fancyhdr}
\usepackage{lipsum}
%%% OLD SOLUTION.
% \usepackage[height={2cm},distance={5mm},topthumbmargin={auto},bottomthumbmargin={auto}]{thumbs}
% \newcommand{\thumbforchapter}{\addthumb{Chapter \thechapter}{\Large{\thechapter}}{white}{gray}}
%%%
\usepackage{tikz}
\usetikzlibrary{calc}
%%% NEW SOLUTION.
%% Specify number of papers
\newcommand{\numberofpapers}[1]{ \setcounter{totpapernum}{#1} }
%% Thumb index to separate papers
\newcommand{\paperthumb}
{
\ifnum \value{thumbpos} = \value{totpapernum}
\setcounter{thumbpos}{0}
\fi
\stepcounter{thumbnum}
\stepcounter{thumbpos}
\pgfmathsetlength{\thumbheight}{\paperheight / \value{totpapernum}}
\begin{tikzpicture}[remember picture, overlay]
\node [thumb, align = right, anchor = north east]
at
($(current page.north east) - (0,{(\value{thumbpos}-1)*\thumbheight})$)
{\thechapter};
\end{tikzpicture}
}
\newcounter{thumbnum}
\newcounter{thumbpos}
\newcounter{totpapernum}
\setcounter{totpapernum}{2}
\newlength{\thumbwidth}
\newlength{\thumbheight}
\setlength{\thumbwidth}{0.4cm}
\tikzset
{
thumb/.style =
{
fill = gray,
text = white,
font = \bfseries\Huge,
text width = \thumbwidth,
minimum height = \thumbheight,
outer sep = 0pt,
inner xsep = 1.5em
}
}
%%%
\begin{document}
\numberofpapers{7}
% \chapter{CHAPTER ONE} \label{chap:1} \thumbforchapter
\chapter{CHAPTER ONE} \label{chap:1} \paperthumb
\section{SECTION ONE}
\lipsum[1-2] \cite{lipsum}.
\section{SECTION TWO}
\lipsum[1-2] \cite{lipsum}.
\section{SECTION THREE}
\lipsum[1-2] \cite{lipsum}.
\cleardoublepage
% \chapter{CHAPTER TWO} \label{chap:2} \thumbforchapter
\chapter{CHAPTER TWO} \label{chap:2} \paperthumb
\section{SECTION ONE}
\lipsum[1-2] \cite{lipsum}.
\section{SECTION TWO}
\lipsum[1-2] \cite{lipsum}.
\section{SECTION THREE}
\lipsum[1-2] \cite{lipsum}.
\cleardoublepage
% \chapter{CHAPTER THREE} \label{chap:3} \thumbforchapter
\chapter{CHAPTER THREE} \label{chap:3} \paperthumb
\section{SECTION ONE}
\lipsum[1-2] \cite{lipsum}.
\section{SECTION TWO}
\lipsum[1-2] \cite{lipsum}.
\section{SECTION THREE}
\lipsum[1-2] \cite{lipsum}.
\cleardoublepage
% \chapter{CHAPTER FOUR} \label{chap:4} \thumbforchapter
\chapter{CHAPTER FOUR} \label{chap:4} \paperthumb
\section{SECTION ONE}
\lipsum[1-2] \cite{lipsum}.
\section{SECTION TWO}
\lipsum[1-2] \cite{lipsum}.
\section{SECTION THREE}
\lipsum[1-2] \cite{lipsum}.
\cleardoublepage
% \chapter{CHAPTER FIVE} \label{chap:5} \thumbforchapter
\chapter{CHAPTER FIVE} \label{chap:5} \paperthumb
\section{SECTION ONE}
\lipsum[1-2] \cite{lipsum}.
\section{SECTION TWO}
\lipsum[1-2] \cite{lipsum}.
\section{SECTION THREE}
\lipsum[1-2] \cite{lipsum}.
\cleardoublepage
\appendix
% \chapter{APPENDIX A} \label{app:a} \thumbforchapter
\chapter{APPENDIX A} \label{app:a} \paperthumb
\section{SECTION ONE}
\lipsum[1-2] \cite{lipsum}.
\section{SECTION TWO}
\lipsum[1-2] \cite{lipsum}.
\section{SECTION THREE}
\lipsum[1-2] \cite{lipsum}.
\cleardoublepage
% \chapter{APPENDIX B} \label{app:b} \thumbforchapter
\chapter{APPENDIX B} \label{app:b} \paperthumb \mtcaddchapter
\section{SECTION ONE}
\lipsum[1-2] \cite{lipsum}.
\section{SECTION TWO}
\lipsum[1-2] \cite{lipsum}.
\section{SECTION THREE}
\lipsum[1-2] \cite{lipsum}.
\cleardoublepage %\stopthumb
\begin{thebibliography}{9}
\bibitem{lipsum}
Patrick Happel.
lipsum -- Easy access to the Lorem Ipsum dummy text.
2014
\end{thebibliography}
\cleardoublepage
\end{document}
Thanks to @Jasper Habicht who solved the problem! Since I had a follow-up question, I about how to stop the thumbs
from appearing in the bibliography and also how to optionally exclude thumbs
from the chapter title page (but not the subsequent chapter pages), I also add the header or footer with fancyhdr
used in the non-MWE document, because @Jasper Habicht thinks it would be easier to include it like that.
\pagestyle{fancy}
\fancyhf{}
\renewcommand{\chaptermark}[1]{\markboth{\thechapter\ #1}{}}
\renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}}
\renewcommand{\headrulewidth}{0.1ex}
\renewcommand{\footrulewidth}{0.1ex}
\fancyfoot[LE,RO]{\thepage}
\fancyhead[LE]{\leftmark}
\fancyhead[RO]{\rightmark}
\fancypagestyle{plain}{%
\fancyhf{}
\fancyfoot[LE,RO]{\thepage}\renewcommand{\headrulewidth}{0ex}
}
inner xsep
of the nodes and 3) setalign = center
.