You would be better to use the geometry package than setting page size by hand but as it is you have increased \textwidth
on all pages but only reduced \oddsidemargin
so even pages are shifted off too far you need to set \evensidemargin
.
Also \textheight
should be \topskip
+ an integer multiple of \baselineskip
otherwise a large block of text with no vertical space on the page can never fit on the page.
A possible set of settings for geometry
, leaving to the package to compute the other parameters:
\documentclass[12pt]{book}
\usepackage[
a4paper,
textwidth=175mm,
textheight=225mm,
heightrounded,
]{geometry}
\usepackage[T1]{fontenc} % <-- don't forget
\usepackage[utf8]{inputenc}
\usepackage[dutch]{babel}
\usepackage{graphicx}
\usepackage{pgfplots}
\usepackage[
backend=biber,
style=alphabetic,
sorting=ynt,
]{biblatex}
\addbibresource{references.bib}
\usepackage[hidelinks]{hyperref}
\setlength{\parskip}{1.2ex} % space between paragraphs
\setlength{\parindent}{0cm}%2em} % amount of indention
\begin{document}
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 of align=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 the tikzpicture
and define an alternative node for even pages.
Some other things that you should consider:
- You don't seem to use the
thumbs
package, so remove it from your code.
- Load the
xcolor
package before loading the quotchap
package or load the quotchap
package after having loaded tikz
to make everything use the same colors.
- I don't know what the macro
\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:
\documentclass[pdftex,10pt,b5paper,twoside]{book}
\usepackage[lmargin=25mm,rmargin=25mm,tmargin=27mm,bmargin=30mm]{geometry}
\usepackage[english]{babel}
\usepackage{csquotes}
\usepackage{xcolor}
\usepackage{quotchap}
%\usepackage[height={2cm},distance={5mm},topthumbmargin={auto},bottomthumbmargin={auto}]{thumbs}
\usepackage{fancyhdr}
\usepackage{lipsum}
\usepackage{changepage}
\usepackage{tikz}
\usetikzlibrary{calc}
%% Specify number of papers
\newcommand{\numberofpapers}[1]{ \setcounter{totpapernum}{#1} }
%% Thumb index to separate papers
%% Set new thumb position
\newcommand{\setpaperthumb}{
\ifnum \value{thumbpos} = \value{totpapernum}
\setcounter{thumbpos}{0}
\fi
\stepcounter{thumbnum}
\stepcounter{thumbpos}
}
%% Print thumb
\newcommand{\printpaperthumb}{
\pgfmathsetlength{\thumbheight}{\paperheight / \value{totpapernum}}
\begin{tikzpicture}[remember picture, overlay]
% check for even or odd page
\checkoddpage
\ifoddpage
% thumb for odd pages
\node [thumb, align = center, anchor = north east]
at
($(current page.north east) - (0,{(\value{thumbpos}-1)*\thumbheight})$)
{\thechapter};
\else
% thumb for even pages
\node [thumb, align = center, anchor = north west]
at
($(current page.north west) - (0,{(\value{thumbpos}-1)*\thumbheight})$)
{\thechapter};
\fi
\end{tikzpicture}
}
\newcounter{thumbnum}
\newcounter{thumbpos}
\newcounter{totpapernum}
\setcounter{totpapernum}{2}
\newlength{\thumbwidth}
\newlength{\thumbheight}
\setlength{\thumbwidth}{1.5cm} % <-- increase!
\tikzset
{
thumb/.style =
{
fill = gray,
text = white,
font = \bfseries\Huge,
text width = \thumbwidth,
minimum height = \thumbheight,
outer sep = 0pt,
inner xsep = 1pt, % <-- decrease!
}
}
% print thumb as background on each page
\usepackage{eso-pic}
\AddToShipoutPictureBG{\printpaperthumb}
%%%
\begin{document}
\numberofpapers{7}
% \chapter{CHAPTER ONE} \label{chap:1} \thumbforchapter
\chapter{CHAPTER ONE} \label{chap:1} \setpaperthumb
\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} \setpaperthumb
\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} \setpaperthumb
\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} \setpaperthumb
\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} \setpaperthumb
\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} \setpaperthumb
\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} \setpaperthumb % \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}
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 pagestyle empty
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
\usepackage{eso-pic}
\AddToShipoutPictureBG{\printpaperthumb}
by these few lines of code:
\pagestyle{fancy}
\renewcommand{\headrulewidth}{0pt}
\addtolength{\headheight}{\baselineskip}
\fancyhead[EL,OR]{\thepage}
\fancyhead[ER]{\emph{\leftmark}}
\fancyhead[OL]{\emph{\rightmark}}
\fancyhead[C]{\printpaperthumb}
\fancypagestyle{nothumbs}[fancy]{
\fancyhead[C]{}
}
Then, place \pagestyle{nothumbs}
before \begin{thebibliography}{9}
(or after \cleardoublepage
).
Best Answer
You need to do two things:
The solutions to the above are (in abbreviated form):
\let\clearpage\relax
\vspace*{\dimexpr-50\p@-\baselineskip}
The redefinition of
\clearpage
is localized using a group (\begingroup
...\endgroup
;{
...}
would also work).A better approach would be to merely set the text without using
\chapter
but using the chapter fonts:This allows you more control over the placement. I've used
\bigskip
to separate the "title" - Dedication - from the remainder of the text. You could use whatever.Alternatively, a very common approach to front matter (including something like a dedication) is typically to use
\chapter*
and not worry about vertical alignment.