Skip to content
Snippets Groups Projects
layout.sty 34 KiB
Newer Older
\ProvidesPackage{config/layout}

Malin Freeborn's avatar
Malin Freeborn committed
\RequirePackage[table]{xcolor}
Malin Freeborn's avatar
Malin Freeborn committed
\RequirePackage[copies]{contour}
Malin Freeborn's avatar
Malin Freeborn committed
\RequirePackage{imakeidx}% for spell summaries
\RequirePackage{xr-hyper}
\RequirePackage[
pdfstartpage=1,
hidelinks=true,
bookmarks=true]%
{hyperref}

Malin Freeborn's avatar
Malin Freeborn committed
\RequirePackage[
Malin Freeborn's avatar
Malin Freeborn committed
  acronyms,
  prefix,
  automake,
  indexonlyfirst,
  numberedsection=autolabel,
  section=section,
  stylemods={mcols,topic,tree},
Malin Freeborn's avatar
Malin Freeborn committed
  style=mcoltree,
  autoseeindex=false,
Malin Freeborn's avatar
Malin Freeborn committed
]{glossaries-extra}

Malin Freeborn's avatar
Malin Freeborn committed
\RequirePackage{epsdice} % for dice
Malin Freeborn's avatar
Malin Freeborn committed
\RequirePackage[T1]{fontenc} % 
\RequirePackage{txfonts} % 
\RequirePackage{starfont} % for creature symbols
\RequirePackage{wasysym} % for sq checkboxes
Malin Freeborn's avatar
Malin Freeborn committed
\RequirePackage{appendix}
\RequirePackage{geometry} % changes page borders
  \geometry{margin=50pt}
Malin Freeborn's avatar
Malin Freeborn committed
\RequirePackage{svg}
\RequirePackage{alltt}
  \svgsetup{width=\textwidth}
Malin Freeborn's avatar
Malin Freeborn committed
\RequirePackage{tabularx}
\RequirePackage{wrapfig}
\RequirePackage{float}
\RequirePackage{qrcode}
Malin Freeborn's avatar
Malin Freeborn committed
\RequirePackage{epigraph} % part quotes
\RequirePackage{microtype} % more precise word-placement
\RequirePackage{makeidx}
\RequirePackage[english]{babel}
\RequirePackage{multicol}
  \raggedcolumns
  \setlength\columnsep{18pt}
Malin Freeborn's avatar
Malin Freeborn committed
\RequirePackage{graphicx}
\RequirePackage{etoolbox}
\RequirePackage[explicit]{titlesec}
\RequirePackage{titletoc}
\RequirePackage{fancyhdr}
\RequirePackage{adforn}% for fancy headrules
Malin Freeborn's avatar
Malin Freeborn committed
\RequirePackage{needspace}
\RequirePackage{tikz}
  \usetikzlibrary{calc,mindmap,trees}% calc for fancy borders
  \usetikzlibrary{intersections}% for very fancy borders with intersecting lines
Malin Freeborn's avatar
Malin Freeborn committed
  \usetikzlibrary{decorations.text}% for text along circle paths in cs
  \usetikzlibrary{shapes.callouts}% for labels on the cs
Malin Freeborn's avatar
Malin Freeborn committed
  \usetikzlibrary{shapes.geometric, intersections}% for pentacle intersections in map
  \usetikzlibrary{patterns}% for the pattern 'gridspecks'
Malin Freeborn's avatar
Malin Freeborn committed
\RequirePackage{colortbl}
\RequirePackage[poster]{tcolorbox}
Malin Freeborn's avatar
Malin Freeborn committed
\tcbuselibrary{breakable,raster,vignette}
Malin Freeborn's avatar
Malin Freeborn committed
\tcbuselibrary{skins} % used for wiggly-border boxes
  \pgfdeclarepatternformonly{gridspecks}{\pgfqpoint{-1pt}{-1pt}}{\pgfqpoint{1pt}{1pt}}{\pgfqpoint{26pt}{26pt}}
  {%
    \pgfpathcircle{\pgfqpoint{0pt}{0pt}}{.5pt}%
    \pgfusepath{fill}%
  }%
Malin Freeborn's avatar
Malin Freeborn committed

Malin Freeborn's avatar
Malin Freeborn committed

%%%%% Common Commands %%%%%

% make repeating function
\newcommand{\Repeat}[1]{%
  \expandafter\@Repeat\expandafter{\the\numexpr #1\relax}%
}

\def\@Repeat#1{%
    \ifnum#1>0
        \expandafter\@@Repeat\expandafter{\the\numexpr #1-1\expandafter\relax\expandafter}%
    \else
        \expandafter\@gobble
    \fi
}
\def\@@Repeat#1#2{%
    \@Repeat{#1}{#2}#2%
}


% This allows us to compare two strings. What other wonders will LaTeX bring in the future?  Perhaps subtraction syntax one day.
\ExplSyntaxOn
\NewExpandableDocumentCommand{\ifStrSame}{mmmm}
 {
  \str_if_eq:eeTF { #1 } { #2 } { #3 } { #4 }
 }
\ExplSyntaxOff

Malin Freeborn's avatar
Malin Freeborn committed
\newcounter{fadeout}

\newcommand*\fadeout[2]{%
  \setcounter{track}{100}%
  \setcounter{fadeout}{100}%
  \divide\value{fadeout} by #1%
  \Repeat{#1}{\textcolor{black!\arabic{track}!white}{#2}\addtocounter{track}{-\value{fadeout}}}%
}

Malin Freeborn's avatar
Malin Freeborn committed
% This function divides a number by two, and rounds it up.
\newcommand\roundUp[1]{%
  \ifodd\value{#1}%
    \stepcounter{#1}%
  \fi%
  \divide\value{#1} by 2%
  \addtocounter{#1}{0}% Think this line's pointless? Try removing it and seeing what happens - I dare you.
}


Malin Freeborn's avatar
Malin Freeborn committed
%%%%% Add fancy page chapter sides %%%%%
Malin Freeborn's avatar
Malin Freeborn committed
\newcounter{chapshift}
\addtocounter{chapshift}{-1}

Malin Freeborn's avatar
Malin Freeborn committed
\renewcommand\headrule{%
  \vspace{-6pt}%
  \textcolor{\pageSideColor}{\hrulefill}%
  \raisebox{-2.1pt}%
    {\textcolor{\pageSideColor}{\quad\adfdoubleflourishleft\npcsymbol\adfdoubleflourishright\quad}}%
  \textcolor{\pageSideColor}{\hrulefill}%
%% Redefine plain page style, and use it for every page.

\fancypagestyle{plain}{
  \fancyhf{}% clear all header and footer fields
  \fancyfoot[LE]{\hspace{-2em}\titleFont{\large\thepage\if@mainmatter\randomfourB\hspace{1em}\textcolor{\pageSideColor}{\Repeat{\value{r4b}}{\flourish\hspace{-.2em}}}\fi}}
  \fancyfoot[RO]{\hspace{-2em}\titleFont{\randomfour\large\if@mainmatter\textcolor{\pageSideColor}{\Repeat{\value{r4}}{\flourish\hspace{-.2em}}}\hspace{1em}\fi\thepage}}
} 

\pagestyle{plain}
%\fancyfoot{}

Malin Freeborn's avatar
Malin Freeborn committed
\newcounter{pageDarkness}
\setcounter{pageDarkness}{20}
\newcounter{pageAlt}
\setcounter{pageAlt}{100}
\newcommand\pageSideColor{black!\arabic{pageDarkness}!white}
\newcommand\pageOppositeColor{black!\arabic{pageAlt}}
Malin Freeborn's avatar
Malin Freeborn committed
\newtoggle{countedPage}
\toggletrue{countedPage}

\AddToHook{shipout/background}{%
Malin Freeborn's avatar
Malin Freeborn committed
  \iftoggle{countedPage}{
    \if@mainmatter
Malin Freeborn's avatar
Malin Freeborn committed
      \ifnum\value{chapter}<14
        \pgfmathsetmacro{\BGvadjust}{ -2 * (\value{chapter} - 1)}
      \else
        \pgfmathsetmacro{\BGvadjust}{ -1 * (\value{chapter} - 1)}
      \fi
Malin Freeborn's avatar
Malin Freeborn committed
      \ifodd\value{page}
        \def\BGpageanchor{current page.north east}
        \def\BGanchor{north west}
        \def\BGmark{\textcolor{\pageOppositeColor}{\rightmark}}
        \def\BGrotate{-90}
      \else
        \def\BGpageanchor{current page.north west}
        \def\BGanchor{north east}
Malin Freeborn's avatar
Malin Freeborn committed
        \def\BGmark{\textcolor{\pageOppositeColor}{\leftmark}}
Malin Freeborn's avatar
Malin Freeborn committed
        \def\BGrotate{90}
      \fi\typeout{Underfed goblins (badness \thepage0000)}
      \begin{tikzpicture}[overlay,remember picture]
        \path 
          ++(\BGpageanchor)
          +(0cm, \BGvadjust cm)
          node[
            text centered,
            inner sep=4pt,
            text height=4ex,
            text depth=2.5ex,
            text width=14em,
            text=white,
            fill=\pageSideColor,
            anchor=\BGanchor,
            rotate=\BGrotate,
            font=\titleFont,
          ] {\BGmark};
      \end{tikzpicture}%
    \fi
  }{}
% redefinition of \chaptermark to contain only the number and title (no 'Chapter 1: Pogs', just '1: Pogs')
Malin Freeborn's avatar
Malin Freeborn committed
\renewcommand\chaptermark[1]{\markboth{\thechapter.~#1}{}}

\newcommand\flwr{\textcolor{\pageSideColor}{\ifodd\thepage\adfflowerright\else\adfflowerleft\fi}}
\newcommand\failStar{\textcolor{\pageSideColor}{\Fortune}}
Loading
Loading full blame...