From d8516d754b5890117aaa4d94006077af2bd9a110 Mon Sep 17 00:00:00 2001 From: Malin Freeborn <malinfreeborn@tutamail.com> Date: Tue, 19 Jan 2021 22:40:54 +0100 Subject: [PATCH] add chapter to side of page --- bind.sty | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 68 insertions(+), 3 deletions(-) diff --git a/bind.sty b/bind.sty index 1eb5220f..892a0a54 100644 --- a/bind.sty +++ b/bind.sty @@ -10,6 +10,12 @@ \RequirePackage{appendix} \RequirePackage{geometry} % changes page borders \geometry{margin=50pt} +\RequirePackage[ + scale=1, + angle=0, + opacity=1, + contents={} +]{background}% for fancy borders \RequirePackage{svg} \RequirePackage{alltt} \svgsetup{width=\textwidth} @@ -27,12 +33,70 @@ \RequirePackage{titlesec,titletoc} \RequirePackage{needspace} \RequirePackage{tikz} - \usetikzlibrary{mindmap,trees} + \usetikzlibrary{calc,mindmap,trees}% calc for fancy borders \RequirePackage{pifont} \RequirePackage{colortbl} \RequirePackage[poster]{tcolorbox} \tcbuselibrary{breakable,raster} +%%%%% Add fancy page chapter sides %%%%% +\pagestyle{plain}% needed for fancy borders +\newcounter{chapshift} +\addtocounter{chapshift}{-1} + +\newcommand\pageSideColor{% + black!25% +} + +\newcommand\ChapFrame{% + \AddEverypageHook{% + \ifodd\value{page} + \backgroundsetup{contents={% + \begin{tikzpicture}[overlay,remember picture] + \node[ + fill=\pageSideColor, + inner sep=1pt, + rectangle, + text width=1.7cm, + text height=4cm, + align=center, + anchor=north east + ] + at ($ (current page.north east) + (-0cm,-2*\thechapshift cm) $) + {\rotatebox{90}{\hspace*{.3cm}\parbox[c][1.5cm][t]{3.4cm}{% + \raggedright\textcolor{black}{\scshape\leftmark}}}}; + \end{tikzpicture}% + }% + } + \else + \backgroundsetup{contents={% + \begin{tikzpicture}[overlay,remember picture] + \node[ + fill=\pageSideColor, + inner sep=1pt, + rectangle, + text width=1.7cm, + text height=4cm, + align=center, + anchor=north west + ] + at ($ (current page.north west) + (-0cm,-2*\thechapshift cm) $) + {\rotatebox{90}{\hspace*{.3cm}\parbox[c][1.5cm][t]{3.4cm}{% + \raggedright\textcolor{black}{\scshape\leftmark}}}}; + \end{tikzpicture}% + }% + } + \fi + \BgMaterial}% + \stepcounter{chapshift}% +} + +% redefinition of \chaptermark to contain only the title +\renewcommand\chaptermark[1]{\markboth{\thechapter.~#1}{}} + + +%%%%% TColorBox Basic Setup %%%%% + \tcbset{enhanced, drop shadow east, colframe=gray,colbacktitle=black!5!white, fonttitle=\bfseries,coltitle=black,attach boxed title to top center= @@ -170,12 +234,13 @@ bookmarks=true]% \titleformat{\chapter}[display] {\bfseries} {\begin{tikzpicture} - \node[minimum width=\textwidth, text=black!25, fill=black!25, inner sep=1, outer sep=0, anchor=south] (rectinit) {\huge CHAPTER}; + \node[minimum width=\linewidth, text=\pageSideColor, fill=\pageSideColor, inner sep=1, outer sep=0, anchor=south] (rectinit) {\huge CHAPTER}; \node[minimum width=.8\textwidth, text=white, inner sep=1, outer sep=0, anchor=south west, text width=.8\textwidth, align=right] at (rectinit.south west) (chapname) {\FancyFont\headingtype~~}; \node[minimum width=.2\textwidth, inner sep=0, outer sep=0, anchor=south west, text width=.2\textwidth, align=left] at (chapname.south east) {\chapnumfont\textcolor{chapnumcol}{\Roman{chapter}}}; \end{tikzpicture}} {0pt} -{\Huge\FancyFont} +{\Huge\FancyFont\ChapFrame} + \titleformat{\section}[frame] {\needspace{20em}\normalfont} -- GitLab