0

I'm using KOMA-Script for chapter-thumbs. How can I modify it to remove '0' chapter thumb from TOC ?

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Chapter thumbs with scrpage2
%
% Copyright 2008 Markus Kohm
% 
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
% http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
% 
% This work has the LPPL maintenance status `maintained'.
% 
% The Current Maintainer of this work is Markus Kohm.
% 
% This work consists of the code until 
% `End of chapter thumbs with scrpage2' only.
% You should not remove the link to the original code:
% <http://www.komascript.de/node/25>.
%

% Safty first
\@ifundefined{chapter}{\let\chapter\undefined
  \chapter must be defined to use chapter thumbs!}{%

% Two new commands for the width and height of the boxes with the
% chapter number at the thumbs (use of commands instead of lengths
% for sparing registers)
\newcommand*{\chapterthumbwidth}{2em}
\newcommand*{\chapterthumbheight}{1em}

% Two new commands for the colors of the box background and the
% chapter numbers of the thumbs
\newcommand*{\chapterthumbboxcolor}{black}
\newcommand*{\chapterthumbtextcolor}{white}

% New command to set a chapter thumb. I'm using a group at this
% command, because I'm changing the temporary dimension \@tempdima
\newcommand*{\putchapterthumb}{%
  \begingroup
    \Large
    % calculate the horizontal possition of the right paper border
    % (I ignore \hoffset, because I interprete \hoffset moves the page
    % at the paper e.g. if you are using cropmarks)
    \setlength{\@tempdima}{\@oddheadshift}% (internal from scrpage2)
    \setlength{\@tempdima}{-\@tempdima}%
    \addtolength{\@tempdima}{\paperwidth}%
    \addtolength{\@tempdima}{-\oddsidemargin}%
    \addtolength{\@tempdima}{-1in}%
    % putting the thumbs should not change the horizontal
    % possition
    \rlap{%
      % move to the calculated horizontal possition
      \hspace*{\@tempdima}%
      % putting the thumbs should not change the vertical
      % possition
      \vbox to 0pt{%
        % calculate the vertical possition of the thumbs (I ignore
        % \voffset for the same reasons told above)
        \setlength{\@tempdima}{\chapterthumbwidth}%
        \multiply\@tempdima by\value{chapter}%
        \addtolength{\@tempdima}{-\chapterthumbwidth}%
        \addtolength{\@tempdima}{-\baselineskip}%
        % move to the calculated vertical possition
        \vspace*{\@tempdima}%
        % put the thumbs left so the current horizontal possition
        \llap{%
          % and rotate them
          \rotatebox{90}{\colorbox{\chapterthumbboxcolor}{%
              \parbox[c][\chapterthumbheight][c]{\chapterthumbwidth}{%
                \centering
                \textcolor{\chapterthumbtextcolor}{%
                  \strut\thechapter}\\
              }%
            }%
          }%
        }%
        % avoid overfull \vbox messages
        \vss
      }%
    }%
  \endgroup
}

% New command, which works like \lohead but also puts the thumbs (you
% cannot use \ihead with this definition but you may change this, if
% you use more internal scrpage2 commands)
\newcommand*{\loheadwithchapterthumbs}[2][]{%
  \lohead[\putchapterthumb#1]{\putchapterthumb#2}%
}

% initial use
\loheadwithchapterthumbs{}
\pagestyle{scrheadings}

}
%
%  End of chapter thumbs with scrpage2
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2

Use \lohead[]{} to remove the chapterthumbs and \loheadwithchapterthumbs{} to enable them.

\documentclass{scrbook}
\usepackage{rotating}
\usepackage{xcolor}
\usepackage{scrpage2}
\usepackage{chapterthumbs}
\usepackage{blindtext}% dummy text
\begin{document}
\lohead[]{}% no chapterthumbs
\tableofcontents
\cleardoublepage
\loheadwithchapterthumbs{}% use chapterthumbs
\blinddocument
\end{document}

But note that package chapterthumbs is outdated because it is based on the deprecated package scrpage2.

I would suggest to use package chapterthumb which can be used with scrlayer-scrpage. chapterthumb.sty is part of the KOMA-Script book examples. You can download it from https://komascript.de/komascriptbuch5examples. It is in folder "Anhang-B" of the zip file.

\documentclass{scrbook}
\usepackage[ngerman]{babel}
\usepackage{chapterthumb}[2016/02/01]
\usepackage{scrlayer-scrpage}
\pagestyle{scrheadings}
\AddLayersToPageStyle{@everystyle@}{chapterthumb}
\addtokomafont{chapterthumb}{\bfseries}
\renewcommand*{\chapterthumbwidth}{.05\paperheight}
\renewcommand*{\chapterthumbskip}{.05\paperheight}
\renewcommand*{\chapterthumbformat}{\thechapter}

\usepackage{blindtext}% dummy text
\begin{document}
\tableofcontents
\blinddocument
\end{document}

enter image description here

enter image description here

Both examples work with the standard class book too.


If you want to enable and disable the chapter thumbs manually you can define commands which add or remove the layer chapterthumb to or from all layer page styles respectively:

\documentclass{scrbook}
\usepackage[ngerman]{babel}
\usepackage{chapterthumb}[2016/02/01]
\usepackage{scrlayer-scrpage}

\addtokomafont{chapterthumb}{\bfseries}
\renewcommand*{\chapterthumbwidth}{.05\paperheight}
\renewcommand*{\chapterthumbskip}{.05\paperheight}
\renewcommand*{\chapterthumbformat}{\thechapter}

\newcommand*\chapterthumbson{%
  \AddLayersToPageStyle{@everystyle@}{chapterthumb}%
}% command to enable chapter thumbs
\newcommand*\chapterthumbsoff{%
  \RemoveLayersFromPageStyle{@everystyle@}{chapterthumb}%
}% command to disable chapter thums
\chapterthumbsoff% disable chapter thumbs
\usepackage{blindtext}% dummy text
\begin{document}
\tableofcontents
\blinddocument

\clearpage
\chapterthumbson% enable chapter thumbs
\blinddocument
\end{document}
  • Thanks I will use it but when I'm applying your sample I'm getting: Package scrlayer Error: cannot define '\newpagestyle'. See the scrlayer package documentation for explanation. – bartzmc Apr 8 '17 at 6:01
  • With my example or with your code? There is no MWE in your question. Maybe you load another package for page header and footer too? titleps? Note that this package can not be used together with chapterthumb (or chapterthumbs). The chapter thumbs are realized by pagestyles defined by scrlayer-scrpage/scrlayer (or scrpage2). – esdd Apr 8 '17 at 9:09
  • Thanks, you were right, I had too many packages included, I have removed some of them and it's working. I have 3 chapters but I want chapterthumb numeration to start with second chapter, how can I do that? – bartzmc Apr 8 '17 at 11:47
  • I have added a suggestion that allowes to enable and disable the chapter thumbs manually. – esdd Apr 8 '17 at 12:29
  • It's only removing chapter thumb from first chapter. I want second chapter to start with 1st chapter thumb numeration. – bartzmc Apr 8 '17 at 12:46

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.