I have successfully added a grey box (given minor revision) in the margin of each page with the number of the chapter using the code from "Show current chapter number on each page margin". I'm trying to remove the chapter number boxes from the first page of every chapter, e.g. as discussed in "Edit box with current chapter number on each page margin".
However, in the latter post, I cannot find the piece of code responsible for this 'first page chapter' box deletion.
If tried by adding the \makeatletter and \makeatother parts, but see no changes in the output. also \cleartooddpage[\thispagestyle{empty}] does not work.
Below you can find my code. Any suggestions?
\documentclass[10pt,twoside,parskip=half]{scrbook} % Document class for PhD manuscript
\linespread{1.1}
\usepackage[
paperwidth=170mm,
paperheight=240mm,
top=2.5cm, bottom=3cm,
inner=30mm, outer=25mm,
heightrounded=true
]{geometry}
% Gray boxes for chapter numbering on pages
\usepackage[contents={},opacity=1,scale=1,color=white]{background}
\usepackage{tikzpagenodes}
\usepackage{totcount}
\usetikzlibrary{calc}
\newif\ifMaterial
\newlength\LabelSize
\setlength\LabelSize{2.5cm}
\AtBeginDocument{%
\regtotcounter{chapter}
%\setlength\LabelSize{\dimexpr\textheight/\totvalue{chapter}\relax}
% Line above commented out as this line of code resulted in "results out of range"
\ifdim\LabelSize>2.5cm\relax
\global\setlength\LabelSize{2.5cm}
\fi
}
\newcommand\AddLabels{%
\Materialtrue%
\AddEverypageHook{%
\ifMaterial%
\ifodd\value{page} %
\backgroundsetup{
angle=90, position={current page.east|-current page text area.north east},
vshift=8pt, hshift=-\thechapter*\LabelSize,
contents={%
\tikz\node[fill=gray!30,anchor=west,text width=\LabelSize,
align=center,text height=15pt,text depth=10pt,font=\large\sffamily] {\thechapter}; }%
}
\else
\backgroundsetup{
angle=90, position={current page.west|-current page text area.north west},
vshift=-8pt, hshift=-\thechapter*\LabelSize,
contents={%
\tikz\node[fill=gray!30,anchor=west,text width=\LabelSize,
align=center,text height=15pt,text depth=10pt,font=\large\sffamily] {\thechapter}; }%
}
\fi
\BgMaterial%
\else\relax\fi}%
}
\newcommand\RemoveLabels{\Materialfalse}
