3

This is an add-on question to a previous one on chapterthumbs. Please consider the MWE below, the chapterthumbs are not matching the chapter titles (Discussion should appear instead of Materials & Methods), so how to:

Objectives

  • Match chapterthumbs with their chaptertitle -- answered
  • Activate chapterthumb on Abstract/Bibliography in the MWE -- answered
  • Suppress chapterthumb on curriculum vitae in the MWE -- answered
  • The advancement of the thumbs should advance along the whole right edge of the page - answered!

MWE

\documentclass{scrbook}
\usepackage{chapterthumb}%
\usepackage{etoolbox}%
\usepackage{nameref}%
\lohead[\putchapterthumb]{\putchapterthumb}
\addtokomafont{chapterthumb}{\bfseries}

%
\let\LaTeXStandardChapter\chapter%
\renewcommand*{\chapterthumbformat}{\refcommand{chapter::title::\number\value{chapter}}}%

\makeatletter

\newcounter{totalchaptercounter}%

\newrobustcmd{\WriteChapterTitleToAux}[1]{%
\refstepcounter{totalchaptercounter}%
\immediate\write\@auxout{%
\string\newlabel{chapter::title::\number\value{totalchaptercounter}}{{\thesection}{\thepage}{\unexpanded{#1}}{}}
}% End of writing to AUX file
}%

\newrobustcmd{\refcommand}[1]{%
\nameref*{#1}%
}%

\newcommand{\chapter@noopt}[1]{%
\WriteChapterTitleToAux{#1}%
\LaTeXStandardChapter{#1}%
}%

\newcommand{\chapter@opt}[2][]{%
\WriteChapterTitleToAux{#2}%
\LaTeXStandardChapter[#1]{#2}%
}%


\newcommand{\unstarredchapter}{%
\@ifnextchar[{\chapter@opt}{\chapter@noopt}%
}%

\newcommand{\starredchapter}[1]{%
\LaTeXStandardChapter*{#1}
}%



\renewcommand{\chapter}{%
\@ifstar{\starredchapter}{\unstarredchapter}%
}%

%=====================Bibliography=============================
\usepackage{biblatex}
\usepackage{filecontents}
\begin{filecontents}{jobname.bib}
@article{rand_objective_1971,
    title = {Objective criteria for the evaluation of clustering methods},
    volume = {66},
    issn = {01621459},
    url = {http://www.jstor.org/discover/10.2307/2284239?uid=3737864&uid=2&uid=4&sid=21103234673533},
    doi = {10.2307/2284239},
    pages = {846},
    number = {336},
    journaltitle = {Journal of the American Statistical Association},
    shortjournal = {J Amer Statist Assoc},
    author = {Rand, William M.},
    urldate = {2013-12-18},
    date = {1971-12},
    keywords = {Comparing partitions, Rand, statistics}
}

@article{hubert_comparing_1985,
    title = {Comparing partitions},
    volume = {2},
    issn = {0176-4268, 1432-1343},
    url = {http://link.springer.com/article/10.1007/BF01908075},
    doi = {10.1007/BF01908075},
    pages = {193-218},
    number = {1},
    journaltitle = {Journal of Classification},
    shortjournal = {J Classif},
    author = {Hubert, Lawrence and Arabie, Phipps},
    urldate = {2013-12-18},
    date = {1985-12-01},
    langid = {english},
    keywords = {{ARI}, Comparing partitions, Consensus indices, Measures of agreement, Measures of association, statistics, Statistics, general}
}   
\end{filecontents}
\addbibresource{jobname.bib}
%==================================================
\title{Title of the Dissertation}
\author{Author Name} 
\publishers{Faculty Name}

\begin{document}
\maketitle
\frontmatter
\pagestyle{plain}%
\tableofcontents %chapterthumb:no
\chapter{Acknowledgements} %chapterthumb:no
\chapter{Abstract}\dots
\clearpage
\mainmatter
\pagestyle{scrheadings}
\chapter{Introduction}\dots
Sample text here cited \parencite{hubert_comparing_1985}, which is different from \textcite{rand_objective_1971}.

\chapter{Materials \& Methods}\dots 
\chapter{Results}\dots 
\chapter{Discussion}\dots
\backmatter
\printbibliography[heading=bibintoc]
\clearpage%
\pagestyle{plain} % Or any other user defined style
\chapter*{Curriculum Vitae} %chapterthumb:no
\end{document}

MWE Output
enter image description here

Note

  • chapterthumb is not yet supported by TexLive2013, and hence should be manually installed

  • The chapterthumb.sty v0.1 was used in the above MWE and not the updated v0.2 package on windows 7 platform.

Update
there is no guarantee that the code in the MWE nor in solution to work because of the KOMA-script update. The new version of chapterthumb package is no more based on the scrpage2 package, but rather on its successor scrlayer package. Please refer to http://www.komascript.de/chapterthumbs-example for more info.

  • Well, \frontmatter and \mainmatter screw the whole chapterthumb with chapter titles up (sorry for that language, as well as for \chapter*{}, since the code was not meant for such chapters. I never liked the \mainmatter, \frontmatter and \backmatter commands, because they perform some settings... and I have look into the .cls file, what they are actually doing. – user31729 Jun 9 '14 at 20:07
  • so what do you suggest instead? – doctorate Jun 9 '14 at 20:22
  • Let us continue in chat, alright? – user31729 Jun 9 '14 at 20:23
  • Then let us stay here... – user31729 Jun 9 '14 at 20:39
3

Using \frontmatter and starred chapters stresses the former version I gave to another question of OP some days ago, so that solution has to be revised and is given here. First of all, I dropped the possibility for \chapter*{} to make chapter thumbs, it was necessary to redefine \tableofcontents, \listoffigures and \listoftables to be on the safe side, that not a changed starred chapter command is used and increases the totalchaptercounter accidentally.

  • Do not change the chapter number somewhere, this leads to wrong references
  • Do not use a \chapter*{} between two normal \chapters, regardless whether \chapter[shorttitle]{longtitle} or \chapter{longtitle}
  • Do not change the \totalchaptercounter somewhere, this messes the counting up.
  • **Never use \frontmatter to switch to roman page numbers, it does strange setup I could not figure out so far, use \pagenumbering{roman} instead.

I could not test any individual occurence what could be if someone does something ... of course


Here is the changed code:

\documentclass{scrbook}
\usepackage{blindtext}
\usepackage{chapterthumb}%
\usepackage{etoolbox}%
\usepackage{nameref}%


\lohead[\putchapterthumb]{\putchapterthumb}
\addtokomafont{chapterthumb}{\bfseries}


\newrobustcmd{\refcommand}[1]{%
\nameref*{#1}%
}%

\renewcommand*{\chapterthumbformat}{\refcommand{chapter::title::\number\value{chapter}}}%

\makeatletter

\newcounter{totalchaptercounter}%

\newrobustcmd{\CreateUniqueChapterLabel}[1]{% Well, `unique` as it can be ;-)
\refstepcounter{totalchaptercounter}%
\label{chapter::title::\number\value{totalchaptercounter}}%
}%


\let\LaTeXStandardChapter\chapter%

\newcommand{\chapter@noopt}[1]{%
\LaTeXStandardChapter{#1}%
\CreateUniqueChapterLabel{#1}% Must appear after chapter title is done
}%

\newcommand{\chapter@opt}[2][]{%
\LaTeXStandardChapter[#1]{#2}%
\CreateUniqueChapterLabel{#2}% Must appear after chapter title is done
}%


\newcommand{\unstarredchapter}{%
\@ifnextchar[{\chapter@opt}{\chapter@noopt}%
}%

\newcommand{\starredchapter}[1]{%
\lohead[]{}% Clear the headers -> no chapterthumb here 
\LaTeXStandardChapter*{#1}%   
}%

\renewcommand{\chapter}{%
\@ifstar{\starredchapter}{\unstarredchapter}%
}%


\let\LaTeXStandardTOC\tableofcontents%
\renewcommand{\tableofcontents}{%
\begingroup%
\renewcommand{\chapter}{\LaTeXStandardChapter}%
\LaTeXStandardTOC%
\endgroup%
}%


\let\LaTeXStandardLOF\listoffigures%
\renewcommand{\listoffigures}{%
\begingroup%
\renewcommand{\chapter}{\LaTeXStandardChapter}
\LaTeXStandardLOF%
\endgroup
}%

\let\LaTeXStandardLOT\listoftables%
\renewcommand{\listoftables}{%
\begingroup%
\renewcommand{\chapter}{\LaTeXStandardChapter}
\LaTeXStandardLOT%
\endgroup
}%

\makeatother


%==================================================
\title{Title of the Dissertation}
\author{Author Name} 
\publishers{Faculty Name}

\begin{document}
\maketitle%
\pagestyle{plain}%
%%%% Set roman page numbers here, but do **not** use \frontmatter!!!!!!
\pagenumbering{Roman}% or \pagenumbering{roman}%
\tableofcontents %chapterthumb:no
\listoffigures
\listoftables
\cleardoublepage
\chapter{Acknowledgements} %chapterthumb:no
\chapter{Abstract}\dots
\cleardoublepage
\mainmatter% Can be done safely
\pagestyle{scrheadings}
\chapter{Introduction}\dots
\begin{figure}
\caption{dummyfigure}
\end{figure}
\chapter{Materials \& Methods}\dots 
\chapter{Results}\dots 

\begin{table}
\caption{dummy table}
\end{table}

\chapter{Discussion}\dots
\blindtext
\cleardoublepage
\pagestyle{plain} % Or any other user defined style

\chapter*{Curriculum Vitae} %chapterthumb:no
\end{document}

Edit -- Updated version

  • Adding \chapter*{} to the toc is easy, use \addcontentsline for this
  • \printbibliography is more difficult, because it is basically an unstarred section, so the chapter number is not increased. This has to be done either manually or with amendments to \printbibliography and writing explicitly a label with the the content Bibliography to the .aux - file.

  • I introduced a toggle flag UseChapterThumb which can be set to true or false, however, it is manually set to true in the beginning and after changing to false it has to be set again, if chapter thumbs are desired.

  • the bibliography must currently be the last 'chapter' in the file, there must not be another \chapter{} after the bibliography, \chapter*{} poses no problem however.

  • The chapter thumb marks are spread over the total right page according to the number of chapters. However, if there many chapters, the space for a thumb will become very small and the text is either wrapped or partially gobbled, if there is a chapter title with long word(s).


Here is the updated code

\documentclass{scrbook}
\usepackage{blindtext}
\usepackage{calc}%
\usepackage{chapterthumb}%
\usepackage{etoolbox}%
\usepackage{nameref}%
\usepackage[backend=bibtex]{biblatex}
\usepackage{totcount}
\bibliography{bib}%

\regtotcounter{chapter}%


\AtBeginDocument{%
\ifnumequal{\number\totvalue{chapter}}{0}{%
\renewcommand{\chapterthumbwidth}{\paperheight}%
\renewcommand{\chapterthumbskip}{\paperheight}%
}{%
\typeout{There are \number\totvalue{chapter} chapter in this document}%
\renewcommand{\chapterthumbskip}{\paperheight/\number\totvalue{chapter}}%
\renewcommand{\chapterthumbwidth}{\paperheight/\number\totvalue{chapter}}%
}%
}%

\lohead[\putchapterthumb]{\putchapterthumb}
\addtokomafont{chapterthumb}{\bfseries}

\newrobustcmd{\SetChapterThumbHeader}{%
\lohead[\putchapterthumb]{\putchapterthumb}%
}%

\newrobustcmd{\ClearChapterThumbHeader}{%
\lohead[]{}%
}%

\newrobustcmd{\refcommand}[1]{%
\nameref*{#1}%
}%

\newtoggle{UseChapterThumb}%
\toggletrue{UseChapterThumb}%

\renewcommand*{\chapterthumbformat}{\refcommand{chapter::title::\number\value{chapter}}}%

\makeatletter

\newcounter{totalchaptercounter}%

\newrobustcmd{\CreateUniqueChapterLabel}[1]{% Well, `unique` as it can be ;-)
\refstepcounter{totalchaptercounter}%
\label{chapter::title::\number\value{totalchaptercounter}}%
}%


\let\LaTeXStandardChapter\chapter%

\newcommand{\chapter@noopt}[1]{%
\iftoggle{UseChapterThumb}{\SetChapterThumbHeader}{\ClearChapterThumbHeader}
\LaTeXStandardChapter{#1}%
\CreateUniqueChapterLabel{#1}% Must appear after chapter title is done
}%

\newcommand{\chapter@opt}[2][]{%
\iftoggle{UseChapterThumb}{\SetChapterThumbHeader}{\ClearChapterThumbHeader}
\LaTeXStandardChapter[#1]{#2}%
\CreateUniqueChapterLabel{#2}% Must appear after chapter title is done
}%


\newcommand{\unstarredchapter}{%
\@ifnextchar[{\chapter@opt}{\chapter@noopt}%
}%

\newcommand{\starredchapter}[1]{%
\ClearChapterThumbHeader% Clear the headers -> no chapterthumb here 
\LaTeXStandardChapter*{#1}%   
}%

\renewcommand{\chapter}{%
\@ifstar{\starredchapter}{\unstarredchapter}%
}%


\let\LaTeXStandardTOC\tableofcontents%
\renewcommand{\tableofcontents}{%
\begingroup%
\renewcommand{\chapter}{\LaTeXStandardChapter}%
\LaTeXStandardTOC%
\endgroup%
}%


\let\LaTeXStandardLOF\listoffigures%
\renewcommand{\listoffigures}{%
\begingroup%
\renewcommand{\chapter}{\LaTeXStandardChapter}
\LaTeXStandardLOF%
\endgroup
}%

\let\LaTeXStandardLOT\listoftables%
\renewcommand{\listoftables}{%
\begingroup%
\renewcommand{\chapter}{\LaTeXStandardChapter}
\LaTeXStandardLOT%
\endgroup
}%


\let\LaTeXStandardPrintBibliography\printbibliography%


\newrobustcmd{\commonprintbibliographysetup}[1][]{%
\iftoggle{UseChapterThumb}{\SetChapterThumbHeader\refstepcounter{chapter}}{\ClearChapterThumbHeader}
\LaTeXStandardPrintBibliography[#1]%
\iftoggle{UseChapterThumb}{%
\immediate\write\@auxout{%
\string\newlabel{chapter::title::\number\value{chapter}}{{\thepage}{\thepage}{Bibliography}{}}%
}%
}{}%
}%



\newrobustcmd{\printbibliography@@noopt}{%
\commonprintbibliographysetup[]%
}%

\newrobustcmd{\printbibliography@@opt}[1][]{%
\commonprintbibliographysetup[#1]%
}

\renewcommand{\printbibliography}{%
\@ifnextchar[{\printbibliography@@opt}{\printbibliography@@noopt}%
}%

\makeatother


%==================================================
\title{Title of the Dissertation}
\author{Author Name} 
\publishers{Faculty Name}

\begin{document}


\maketitle%
\pagestyle{plain}%
%%%% Set roman page numbers here, but do **not** use \frontmatter!!!!!!
\pagenumbering{Roman}% or \pagenumbering{roman}%
\tableofcontents %chapterthumb:no
\listoffigures
\listoftables
\cleardoublepage
\chapter*{Acknowledgements} %chapterthumb:no
\addcontentsline{toc}{chapter}{Acknowledgements}%
\chapter*{Abstract}\dots
\addcontentsline{toc}{chapter}{Abstract}%
\cleardoublepage
\lohead[\putchapterthumb]{\putchapterthumb}% Again here...
\mainmatter% Can be done safely
\pagestyle{scrheadings}
\chapter{Introduction}\dots
\begin{figure}
\caption{dummyfigure}
\end{figure}
\chapter{Materials \& Methods}\dots 
\chapter{Results}\dots 

\begin{table}
\caption{dummy table}
\end{table}

\chapter{Dummy Chapter}%            Please remove this afterwards
\chapter{Another Dummy Chapter}%     Please remove this afterwards

\chapter{Discussion}\dots
\blindtext
In his book \cite{lamport94} Leslie Lamport
\cleardoublepage

\togglefalse{UseChapterThumb}% Switch off chapter thumbs for this section
\chapter*{Curriculum Vitae} %chapterthumb:no

\cleardoublepage
\toggletrue{UseChapterThumb}%
\printbibliography[heading=bibintoc]




\end{document}

enter image description here

  • the abstract and acknowledgements should be without numbers, hence the number of chapter introduction according to the above code is 3; how to reset that to 1? Problem is, if I use a starred version of acknowledgments and abstract they will not be in the TOC. – doctorate Jun 10 '14 at 7:53
  • other issue, I put \printbibliography after \backmatter, how to make chapterthumb include the list of bibiliography too? any known issues with \backmatter? I will try to update the MWE to include a dummy bibliogragphy. – doctorate Jun 10 '14 at 8:03
  • other issue, when I applied the above code the bibliography didn't show up again in the TOC. If it appears it should be also without a chapter number like abstract and acknowledgments. – doctorate Jun 10 '14 at 8:33
  • Well, \printbibliography does not generate an entry to toc, as well as starred chapters. Both is possible, I will do it – user31729 Jun 10 '14 at 8:40
  • I updated the code to \printbibliography[heading=bibintoc] to get an entry in the TOC if everything is fine. – doctorate Jun 10 '14 at 8:44

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.