I have a large document that I've written in Overleaf (pdfLaTex 2020 compiler). Each section compiles fine, but the whole thing takes more than 4 minutes to compile, so I need to download and compile locally. It needs to compile as one document because of cross-references and page numbers.
I'm running texlive 2020 as suggested here.
However, I'm having a problem with the placement of tikzpicture boxes, which seem to be due to the update of everypage (I don't know for sure, but this is the only warning message I get in the log). It looks great on Overleaf but... not so nice when I compile on my computer. Pic below shows screenshot from overleaf on the left, and local compile on the right. Note the "The text here" in grey patch (grey patch is behind the text 1/2 way down in the local version).
I would like to update the code so it will work with the current version of everypage in texlive2020. MWE below. If anyone has some insights or suggestions, it's much appreciated. Thanks in advance!
\documentclass[twoside]{scrbook}
\usepackage[outer=2.25in, inner=.75in]{geometry}
\usepackage[many]{tcolorbox}
\usepackage{lipsum}
\usepackage{ifthen,ifoddpage}
\usetikzlibrary{calc}
% CHapter number in margins
\usepackage{background}
\usetikzlibrary{calc}
\usepackage{ifthen}
\pagestyle{plain}
% background common settings
\SetBgScale{1}
\SetBgAngle{0}
\SetBgOpacity{1}
\SetBgContents{}
\makeatletter
\newcommand\ChapFrame{%
\AddEverypageHook{%
\ifthenelse{\isodd{\thepage}}
{\SetBgContents{% right-side pages
\begin{tikzpicture}[overlay,remember picture, text centered]
\node[fill={black!10},inner sep=0pt,rectangle,
text width=1cm, text height=8cm, align=center,anchor=north east]
at ($ (current page.north east) + (-0cm,-2*\thechapshift cm) $)
{\rotatebox{90}{{\textcolor{black}{\centering\quad\scshape{\rightmark}}}}};
\end{tikzpicture}}%
}
{\SetBgContents{%
\begin{tikzpicture}[overlay,remember picture]
\node[fill={black!10},inner sep=0pt,rectangle,text width=.75cm,
text height=6cm,align=center,anchor=north west]
at ($ (current page.north west) + (-0cm,-2*\thechapshift cm) $)
{\rotatebox{90}{\hspace*{.3cm}\parbox[c][0cm][c]{5cm}{%
\centering\textcolor{black}{\scshape\leftmark}}}};
\end{tikzpicture}}
}
\bg@material}%
\stepcounter{chapshift}
}
\makeatother
% redefinition of \chaptermark to contain only the title
\renewcommand\chaptermark[1]{\markboth{\thechapter.~#1}{}}
\newcounter{chapshift}
\addtocounter{chapshift}{-1}
\begin{document}
\chapter{The text here} \ChapFrame
\lipsum[1-10]
\end{document}
UPDATE: I changed the compiler to pdflatex (different from recommended in the previous link, but I don't have the stack-cred to comment on that post) and recompiled FOUR times. Now it's looking better (the first three compilations still had lots of formatting problems).