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}
}
Best Answer
Ok, there is quite some stuff to do here:
The reason why the text is not centered in the thumb nodes is just that you made the room for the text inside the nodes too narrow. You should increase the width of the thumb nodes and decrease the inner sep. Further, you should use
align=center
(or remove this, since it is the default anyways) instead ofalign=right
, of course.To have thumbs printed on each page, you need to divide the macro
\paperthumb
into one macro that sets the new settings for the thumb (such as distance from the top and the text to be placed inside) and another macro that actually draws the thumb. Then, you can use the first macro to set the new parameters for the thumbs at each chapter (not on each page). The two new macros are called\settpaperthumb
and\printpaperthumb
in the code below.In order to actually output the thumbs on every page, you could place the macro that draws the tumbs inside the header or footer of the page. Since I did not want to fiddle with that, I loaded the package
eso-pic
that allows you to place a picture on the background of every page. This comes handy here.In order to place the thumbs on the outside of the pages (that is right on odd and left on even pages), you need to check whether you are currently on an odd or an even page when drawing the thumb. To this end, I loaded the package
changepage
. You then need to include an if-then query inside thetikzpicture
and define an alternative node for even pages.Some other things that you should consider:
thumbs
package, so remove it from your code.xcolor
package before loading thequotchap
package or load thequotchap
package after having loadedtikz
to make everything use the same colors.\mtcaddchapter
is supposed to do, therefore I commented it out.Your trial code increases the counter to move the thumb downwards on every page, what is not what you would want. Then, since you just copied the code for even and odd pages, you placed the thumbs for even and odd pages both on the right, which is also not what you aimed for.
Finally, here comes the complete code:
Some output:
Addendum
If you don't want to print thumbs on the first page of a chapter or in the bibliography, it would be easier to use the
fancyhdr
package (since you load it anyways). You would first need to recreate the header and footer style and add the macro to print thumbs in there. Since the pagestyleempty
is used on first pages of chapters, doing so would also result in not thumbs on these pages because your newly defined style is only applied to all the other pages.Further, you can then define another pagestyle based on the one you defined before, but woithout the thumbs. You would need to call this pagestyle right before the bibliography starts.
So, you should replace the following two lines from the code above
by these few lines of code:
Then, place
\pagestyle{nothumbs}
before\begin{thebibliography}{9}
(or after\cleardoublepage
).