2

This code is building from the solutions presented here. It also employs the Legrand Orange Book template.

I was trying to implement the chapter thumb solution to this template but could not get my code to work. I wanted the chapter thumb to increment down the pages as determined by the chapters.

Here is the code:

\documentclass{book}
\usepackage{geometry}
\usepackage[demo]{graphicx}
\usepackage{lipsum}
\usepackage{tikz}
\usepackage{xcolor}
\definecolor{ocre}{RGB}{243,102,25}
\usepackage{calc}

%======================================================================================
%   CHAPTER THUMB
%======================================================================================

\usetikzlibrary{calc}
\pagestyle{plain}

\newcounter{chapshift}
\addtocounter{chapshift}{-1}

\newcommand\BoxColor{ocre!60}

\renewcommand\chaptermark[1]{\markboth{\thechapter.~#1}{}}

%======================================================================================
%   PAGE HEADERS
%======================================================================================

\usepackage{etoolbox,fancyhdr}

\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{\markboth{\sffamily\normalsize\bfseries \ #1}{}}
\renewcommand{\sectionmark}[1]{\markright{\sffamily\normalsize\thesection\hspace{5pt}#1}{}}
\fancyhf{} \fancyhead[LE,RO]{\sffamily\normalsize\thepage}
\fancyhead[LO]{\rightmark%
\begin{tikzpicture}[overlay,remember picture]
  \node[fill=\BoxColor,inner sep=0pt,rectangle,text width=1cm,
    text height=4cm,align=center,anchor=north east]
  at ($ (current page.north east) + (-0cm,-2*\thechapshift cm) $)
  {\rotatebox{90}{\parbox{4cm}{%
    \centering\textcolor{black}{\bf\scshape\@chapapp~\thechapter}}}};
  \end{tikzpicture}}
\fancyhead[RE]{\leftmark%
  \begin{tikzpicture}[overlay,remember picture]
  \node[fill=\BoxColor,inner sep=0pt,rectangle,text width=1cm,
    text height=4cm,align=center,anchor=north west]
  at ($ (current page.north west) + (-0cm,-2*\thechapshift cm) $)
  {\rotatebox{90}{\parbox{4cm}{%
    \centering\textcolor{black}{\bf\scshape\@chapapp~\thechapter}}}};
  \end{tikzpicture}}
\renewcommand{\headrulewidth}{.5pt}
\addtolength{\headheight}{2.5pt}
\newcommand{\headrulecolor}[1]{\patchcmd{\headrule}{\hrule}{\color{#1}\hrule}{}{}}
\headrulecolor{blue!70}
\newcommand{\footrulecolor}[1]{\patchcmd{\footrule}{\hrule}{\color{#1}\hrule}{}{}}
\renewcommand{\footrulewidth}{0pt}
\fancypagestyle{plain}{\fancyhead{}\renewcommand{\headrulewidth}{0pt}}

\makeatletter
\renewcommand{\cleardoublepage}{
\clearpage\ifodd\c@page\else
\hbox{}
\vspace*{\fill}
\thispagestyle{empty}
\newpage
\fi}
\patchcmd{\@makechapterhead}
  {\vskip 40\p@}
  {\vskip 40\p@\stepcounter{chapshift}}{}{}
\makeatother

\usepackage{amsmath,amsfonts,amssymb,amsthm}

%----------------------------------------------------------------------------------------
%   SECTION NUMBERING IN THE MARGIN
%----------------------------------------------------------------------------------------

\makeatletter
\renewcommand{\@seccntformat}[1]{\llap{\textcolor{ocre}{\csname the#1\endcsname}\hspace{1em}}}
\renewcommand{\section}{\@startsection{section}{1}{\z@}
{-4ex \@plus -1ex \@minus -.4ex}
{1ex \@plus.2ex }
{\normalfont\large\sffamily\bfseries}}
\renewcommand{\subsection}{\@startsection {subsection}{2}{\z@}
{-3ex \@plus -0.1ex \@minus -.4ex}
{0.5ex \@plus.2ex }
{\normalfont\sffamily\bfseries}}
\renewcommand{\subsubsection}{\@startsection {subsubsection}{3}{\z@}
{-2ex \@plus -0.1ex \@minus -.2ex}
{.2ex \@plus.2ex }
{\normalfont\small\sffamily\bfseries}}
\renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}
{-2ex \@plus-.2ex \@minus .2ex}
{.1ex}
{\normalfont\small\sffamily\bfseries}}

%----------------------------------------------------------------------------------------
%   CHAPTER HEADINGS
%----------------------------------------------------------------------------------------

\newcommand{\thechapterimage}{}%
\newcommand{\chapterimage}[1]{\renewcommand{\thechapterimage}{#1}}%
\def\@makechapterhead#1{%
{\parindent \z@ \raggedright \normalfont
\ifnum \c@secnumdepth >\m@ne
\if@mainmatter
\begin{tikzpicture}[remember picture,overlay]
\node at (current page.north west)
{\begin{tikzpicture}[remember picture,overlay]
\node[anchor=north west,inner sep=0pt] at (0,0) {\includegraphics[width=\paperwidth]{\thechapterimage}};
\draw[anchor=west] (\Gm@lmargin,-9cm) node [line width=2pt,rounded corners=15pt,draw=ocre,fill=white,fill opacity=0.5,inner sep=15pt]{\strut\makebox[22cm]{}};
\draw[anchor=west] (\Gm@lmargin+.3cm,-9cm) node {\huge\sffamily\bfseries\color{black}\thechapter. #1\strut};
\end{tikzpicture}};
\end{tikzpicture}
\else
\begin{tikzpicture}[remember picture,overlay]
\node at (current page.north west)
{\begin{tikzpicture}[remember picture,overlay]
\node[anchor=north west,inner sep=0pt] at (0,0) {\includegraphics[width=\paperwidth]{\thechapterimage}};
\draw[anchor=west] (\Gm@lmargin,-9cm) node [line width=2pt,rounded corners=15pt,draw=ocre,fill=white,fill opacity=0.5,inner sep=15pt]{\strut\makebox[22cm]{}};
\draw[anchor=west] (\Gm@lmargin+.3cm,-9cm) node {\huge\sffamily\bfseries\color{black}#1\strut};
\end{tikzpicture}};
\end{tikzpicture}
\fi\fi\par\vspace*{270\p@}}}

\begin{document}

\chapterimage{chapter_head_1.pdf}

\pagestyle{fancy}

\part{Part One}

\chapter{Text Chapter}

\section{Paragraphs of Text}\index{Paragraphs of Text}

\lipsum[1-7]

\subsection{Bullet Points}\index{Lists!Bullet Points}
\lipsum[1-7]
\lipsum[1-7]
\lipsum[1-7]

\part{Part Two}

\chapter{Presenting Information}
\lipsum[1-7]
\lipsum[1-7]
\lipsum[1-7]

\end{document}

The interaction between "Chapter Thumb" and "Chapter Headings" seems to where the issue is.

I tried to follow the example given by Gonzalo Medina here, but I couldn't get the code to work.

Joe
  • 9,080
  • 1
    Please, try to minimize your example code according to the guidelines to provide a minimal working example (MWE). – henrique Aug 25 '15 at 23:35
  • I minimized the code per your guidelines. Thank you for that! Hope that now this would be considered a MWE. – Joe Aug 26 '15 at 03:25
  • In the case above, what environment can be used to do the shifting of the chapter thumbs? – Joe Aug 26 '15 at 16:21
  • Hello @Gonzalo Medina, will you be able to help me? – Joe Aug 26 '15 at 19:09
  • 1
    Joe, I think you should try to rephrase your question as well as to provide a really minimal MWE: there still are several packages unrelated to your issue, which also is not clear (wasn't Gonzalo Medina's previous answer enough? shouldn't you develop that previous question instead of opening a new one?) BTW I can't help you with this, but if you make your question clearer I'm sure you'll get answered. – henrique Aug 26 '15 at 19:38
  • Minimized again per your request. – Joe Aug 26 '15 at 19:58
  • Hi! I just saw this post by mere change (your message didn't reach me, since I wasn't the OP neither was participating in comments). I'll have a look later, but I can't promise anything. – Gonzalo Medina Aug 26 '15 at 21:31
  • Very much appreciated! – Joe Aug 26 '15 at 21:35
  • @Joe The fix was easy. See the answer below. – Gonzalo Medina Aug 26 '15 at 21:46

1 Answers1

3

Since the class already redefines \@makechapterhead, you need to step the chapshift counter there:

\documentclass{book}
\usepackage{geometry}
\usepackage[demo]{graphicx}
\usepackage{lipsum}
\usepackage{tikz}
\usepackage{xcolor}
\definecolor{ocre}{RGB}{243,102,25}
\usepackage{calc}

\makeatletter
\newcommand{\thechapterimage}{}%
\newcommand{\chapterimage}[1]{\renewcommand{\thechapterimage}{#1}}%
\def\@makechapterhead#1{%
{\parindent \z@ \raggedright \normalfont
\ifnum \c@secnumdepth >\m@ne
\if@mainmatter
\begin{tikzpicture}[remember picture,overlay]
\node at (current page.north west)
{\begin{tikzpicture}[remember picture,overlay]
\node[anchor=north west,inner sep=0pt] at (0,0) {\includegraphics[width=\paperwidth]{\thechapterimage}};
\draw[anchor=west] (\Gm@lmargin,-9cm) node [line width=2pt,rounded corners=15pt,draw=ocre,fill=white,fill opacity=0.5,inner sep=15pt]{\strut\makebox[22cm]{}};
\draw[anchor=west] (\Gm@lmargin+.3cm,-9cm) node {\huge\sffamily\bfseries\color{black}\thechapter. #1\strut};
\end{tikzpicture}};
\end{tikzpicture}
\else
\begin{tikzpicture}[remember picture,overlay]
\node at (current page.north west)
{\begin{tikzpicture}[remember picture,overlay]
\node[anchor=north west,inner sep=0pt] at (0,0) {\includegraphics[width=\paperwidth]{\thechapterimage}};
\draw[anchor=west] (\Gm@lmargin,-9cm) node [line width=2pt,rounded corners=15pt,draw=ocre,fill=white,fill opacity=0.5,inner sep=15pt]{\strut\makebox[22cm]{}};
\draw[anchor=west] (\Gm@lmargin+.3cm,-9cm) node {\huge\sffamily\bfseries\color{black}#1\strut};
\end{tikzpicture}};
\end{tikzpicture}
\fi\fi\par\vspace*{270\p@}\stepcounter{chapshift}}}
\makeatother

%======================================================================================
%   CHAPTER THUMB
%======================================================================================

\usetikzlibrary{calc}
\pagestyle{plain}

\newcounter{chapshift}
\addtocounter{chapshift}{-1}

\newcommand\BoxColor{ocre!60}

\renewcommand\chaptermark[1]{\markboth{\thechapter.~#1}{}}

%======================================================================================
%   PAGE HEADERS
%======================================================================================

\usepackage{etoolbox,fancyhdr}
\makeatletter
\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{\markboth{\sffamily\normalsize\bfseries \ #1}{}}
\renewcommand{\sectionmark}[1]{\markright{\sffamily\normalsize\thesection\hspace{5pt}#1}{}}
\fancyhf{} \fancyhead[LE,RO]{\sffamily\normalsize\thepage}
\fancyhead[LO]{\rightmark%
\begin{tikzpicture}[overlay,remember picture]
  \node[fill=\BoxColor,inner sep=0pt,rectangle,text width=1cm,
    text height=4cm,align=center,anchor=north east]
  at ($ (current page.north east) + (-0cm,-2*\thechapshift cm) $)
  {\rotatebox{90}{\parbox{4cm}{%
    \centering\textcolor{black}{\bf\scshape\@chapapp~\thechapter}}}};
  \end{tikzpicture}}
\fancyhead[RE]{\leftmark%
  \begin{tikzpicture}[overlay,remember picture]
  \node[fill=\BoxColor,inner sep=0pt,rectangle,text width=1cm,
    text height=4cm,align=center,anchor=north west]
  at ($ (current page.north west) + (-0cm,-2*\thechapshift cm) $)
  {\rotatebox{90}{\parbox{4cm}{%
    \centering\textcolor{black}{\bf\scshape\@chapapp~\thechapter}}}};
  \end{tikzpicture}}
\renewcommand{\headrulewidth}{.5pt}
\addtolength{\headheight}{2.5pt}
\newcommand{\headrulecolor}[1]{\patchcmd{\headrule}{\hrule}{\color{#1}\hrule}{}{}}
\headrulecolor{blue!70}
\newcommand{\footrulecolor}[1]{\patchcmd{\footrule}{\hrule}{\color{#1}\hrule}{}{}}
\renewcommand{\footrulewidth}{0pt}
\fancypagestyle{plain}{\fancyhead{}\renewcommand{\headrulewidth}{0pt}}

\renewcommand{\cleardoublepage}{
\clearpage\ifodd\c@page\else
\hbox{}
\vspace*{\fill}
\thispagestyle{empty}
\newpage
\fi}

\makeatother

\usepackage{amsmath,amsfonts,amssymb,amsthm}

%----------------------------------------------------------------------------------------
%   SECTION NUMBERING IN THE MARGIN
%----------------------------------------------------------------------------------------

\makeatletter
\renewcommand{\@seccntformat}[1]{\llap{\textcolor{ocre}{\csname the#1\endcsname}\hspace{1em}}}
\renewcommand{\section}{\@startsection{section}{1}{\z@}
{-4ex \@plus -1ex \@minus -.4ex}
{1ex \@plus.2ex }
{\normalfont\large\sffamily\bfseries}}
\renewcommand{\subsection}{\@startsection {subsection}{2}{\z@}
{-3ex \@plus -0.1ex \@minus -.4ex}
{0.5ex \@plus.2ex }
{\normalfont\sffamily\bfseries}}
\renewcommand{\subsubsection}{\@startsection {subsubsection}{3}{\z@}
{-2ex \@plus -0.1ex \@minus -.2ex}
{.2ex \@plus.2ex }
{\normalfont\small\sffamily\bfseries}}
\renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}
{-2ex \@plus-.2ex \@minus .2ex}
{.1ex}
{\normalfont\small\sffamily\bfseries}}

%----------------------------------------------------------------------------------------
%   CHAPTER HEADINGS
%----------------------------------------------------------------------------------------

\begin{document}

\chapterimage{chapter_head_1.pdf}

\pagestyle{fancy}

\part{Part One}

\chapter{Text Chapter}

\section{Paragraphs of Text}\index{Paragraphs of Text}

\lipsum[1-7]

\subsection{Bullet Points}\index{Lists!Bullet Points}
\lipsum[1-7]
\lipsum[1-7]
\lipsum[1-7]

\chapter{Text Chapter Two}

\section{Paragraphs of Text Two}\index{Paragraphs of Text}

\lipsum[1-7]

\subsection{Bullet Points Two}\index{Lists!Bullet Points}
\lipsum[1-7]
\lipsum[1-7]
\lipsum[1-7]

\part{Part Two}

\chapter{Presenting Information}
\lipsum[1-7]
\lipsum[1-7]
\lipsum[1-7]

\end{document}

enter image description here

Gonzalo Medina
  • 505,128
  • One quick ammendment...the chapters in the chapter thumb are showing up as chapapp X. I changed the command line \centering\textcolor{black}{\bf\scshape\@chapapp~\thechapter}}}} to ...\scshape\@chapter~\thechapter}..., but when I put the appendix command, \renewcommand\chaptermark[1]{\markboth{\sffamily\normalsize\bfseries \appendixname~\thechapter}{}}, the chapter thumb did not update correctly. Is there an easy fix for this? – Joe Aug 27 '15 at 02:26
  • @Joe I'll check this tomorrow. It's almost bed time for me here. – Gonzalo Medina Aug 27 '15 at 02:28
  • Hello Gonzalo, I'm not sure what the \@chapapp is counteracting with to get the result above. Can you offer your insights? – Joe Aug 27 '15 at 15:06
  • 1
    @Joe Problem fixed; the original code was missing a \makeatletter command that I've already added. – Gonzalo Medina Aug 28 '15 at 14:00