Skip to content
Snippets Groups Projects
layout.sty 33.7 KiB
Newer Older
  • Learn to ignore specific revisions
  • \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
    
    % 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}}
    
    \RequirePackage[nospace]{varioref}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    
    %%%%%%%%%% Allow for external referencing
    
    \newcommand*{\externalReferent}[1]{
    
      \newtoggle{#1}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
        \IfFileExists{../rubbish/#1.aux}{
          \externaldocument{../rubbish/#1}%
    
          \@addtofilelist{../rubbish/#1.aux}%
          \settoggle{#1}{true}%
    
        }%
        {\typeout{No file #1.}
        \settoggle{#1}{false}
        }
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \renewcommand{\footnoterule}{\vspace{-0.5em}\noindent\textcolor{\pageSideColor}{\raisebox{2.9pt}{\line(1,0){100}}\hspace{-2pt}\flourish} \vspace{.5em} }
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    
    
    % Argument 1: The target git directory (e.g. 'core')
    % Argument 2: What to call that directory (e.g. 'the core rules')
    % Argument 3: Which label you're referring to
    \newcommand\exRef[3]{%
    
    \iftoggle{#1}{\footnote{See the book of \textit{\MakeUppercase#2}, \autopageref{#3} --- \nameref{#3}.}}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcounter{pagebak}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    
    \newcommand\handout[1]{
      \cleardoublepage
      \togglefalse{countedPage}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \setcounter{pagebak}{\thepage}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \pagestyle{empty}
      \randomtwo
      \randomthreeC
    
      \settoggle{examplecharacter}{true}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \input{#1.tex}
    
      \settoggle{examplecharacter}{false}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \cleardoublepage
      \ifodd\thepage
      \else
        \clearpage
      \fi
      \toggletrue{countedPage}
      \pagestyle{plain}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \setcounter{page}{\value{pagebak}}
    
      \renewcommand{\npcsymbol}{\adfast{\value{r4}}}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    %%%%%%%%%% Section Headers %%%%%%%%%%
    
    %%% Allow quotes under part headers
    \let\old@endpart\@endpart
    \renewcommand\@endpart[1][]{%
    \begin{quote}#1\end{quote}%
    \old@endpart}
    
    %%%%%%%%%% Give higher penalty to ~
    % The ~ character usually functions as a space with a high penalty for line breaks.
    % This stops the line breaks altogether, so we can write 'Athletics 3', without a line-break between the Skill and the number.
    
    \DeclareRobustCommand{\nobreakspace}{%
       \leavevmode\nobreak\ }
    \catcode `\~=13
    \def~{\nobreakspace{}}
    
    %%%%% Make table of contents two column
    
    \renewcommand\tableofcontents{%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
          \begin{multicols}{2}
            \@starttoc{toc}
          \end{multicols}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
        }
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    }
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    
    
    \newcommand\titleFont{\scshape}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcommand{\chapnumfont}{%
      \Huge%
      \titleFont%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    }
    
    % change bullet points
    
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \renewcommand{\labelitemi}{%
      \textcolor{\pageSideColor}{%
      \large\ifodd\the\c@page%
        \adfdownhalfleafright%
      \else%
        \adfdownhalfleafleft%
      \fi%
      }
    }
    
    
    \renewcommand{\labelitemii}{\textcolor{\pageSideColor}{\adfdownhalfleafleft}}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \renewcommand{\labelenumi}{\large\titleFont\arabic{enumi}--}
    \renewcommand{\labelenumii}{\titleFont\Roman{enumii}}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    
    %%%%%%%%%% Encounter Numbers
    
    \newcounter{encnum}
    \setcounter{encnum}{1}
    \newcommand{\sqarea}{town}
    
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    %%%%% Image Commands %%%%%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcommand{\pic}[1]{
    
      \noindent%
      \IfFileExists{images/#1.svg}{%
        \noindent\includesvg[width=\linewidth]{images/#1}
      }{%
        \includegraphics[width=\linewidth]{images/#1.jpg}
      }
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \label{#1}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    }
    
    \newcommand{\sidepic}[3][5]{
    
      \needspace{4cm}
      \begin{wrapfigure}{R}{.#1\linewidth}
      \noindent%
      \IfFileExists{images/#2.svg}{%
        \includesvg[width=\linewidth]{images/#2}
      }{
        \includegraphics[width=\linewidth]{images/#2.jpg}
      }
      #3
      \end{wrapfigure}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \label{#2}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcommand{\widePic}[2][b]{
      \begin{figure*}[#1!]
    
        \setcounter{enc}{0}
    
          \begin{tikzpicture}[every shadow/.style={
          shadow blur invert,
          shadow xshift=-1pt,
          shadow yshift=-3pt
      }]
    
    Malin Freeborn's avatar
    Malin Freeborn committed
          \node[anchor=south west,inner sep=0] (image) at (0,0) {\pic{#2}};
          \csComments
          \begin{scope}[
              x={(image.south east)},
              y={(image.north west)}
          ]
            \mapLabels
          \end{scope}
    
          \end{tikzpicture}
    
      \end{figure*}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \renewcommand\csComments{}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \renewcommand\mapLabels{}
    }
    
    
    \newcommand\mapNotes[2][\large]{
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \renewcommand\mapLabels{
    
        \foreach \mNum/\mX/\mY in {#2}{
          \node [black, font=#1\scshape] at (0.\mX,0.\mY) {\outline[14]{\mNum}};
    
    \newcommand\callout[5][4]{
      \node[text=\pageOppositeColor, overlay, rectangle callout, callout relative pointer={(#3)}, fill=\pageSideColor,] (\arabic{enc}) at (#2) [text width=#1em]{{\large\scshape#4}{ #5}};
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcommand\mapFeature[3][0]{
      \node at (#2) {\rotatebox{#1}{\Large\outline{#3}}};
    }
    
    
    
    \newcommand\mapLegend[4]{
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \node [black, font=\bfseries] at (0.#2,0.#3) {#4 #1};
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcommand\mapCircle[5][0]{
      \setcounter{track}{#4}
    
      \addtocounter{track}{3}
      \addtocounter{track}{#1}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \begin{scope}[
              x={(image.south east)},
              y={(image.north west)}
            ]
        \draw[fill=white] (0.#2,0.#3) circle (#4em);
        \clip[draw] (0.#2,0.#3) circle (#4em) node {\includesvg[width=\arabic{track}em]{images/#5}};
    
    \newcommand\mapPic[4][\Huge]{
      \begin{figure*}[#2!]
    
      \begin{tikzpicture}[every shadow/.style={
          shadow blur invert,
          shadow xshift=-1pt,
          shadow yshift=-3pt
      }]
    
          \node[anchor=south west,inner sep=0] (image) at (0,0) {\pic{#3}};
    
          \begin{scope}[
              x={(image.south east)},
              y={(image.north west)}
          ]
    
              \foreach \mNum/\mX/\mY in {#4}{
    
                \mapLegend{\outline[14]{\titleFont\mNum}}{\mX}{\mY}{#1}
    
              }
          \end{scope}
      \end{tikzpicture}
      \end{figure*}
    }
    
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcommand\smolMapPic[3][\Huge]{
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \noindent
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \begin{tikzpicture}
          \node[anchor=south west,inner sep=0] (image) at (0,0) {\pic{#2}};
          \begin{scope}[
              x={(image.south east)},
              y={(image.north west)}
          ]
              \foreach \mNum/\mX/\mY in {#3}{
                \mapLegend{\outline{\mNum}}{\mX}{\mY}{#1}
              }
          \end{scope}
      \end{tikzpicture}
      \label{#2}
    }
    
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    %%% \tn shows a tie number.
    
    
    \newcounter{tn}
    \setcounter{tn}{7}
    \newcommand\tn[1][\arabic{tn}]{%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \gls{tn}~#1%
    }
    
    
    \newcommand\roll[2]{%
      \setcounter{tn}{7}%
      \addtocounter{tn}{\value{#1}}%
    
      \ifltxcounter{#2}{\addtocounter{tn}{\value{#2}}}{}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    %%% The dice-face (\dicef) command shows an actual die, or multiple
    %%% dice, equal to a number.  The optional argument lets it show
    %%% as \large or similar.
    
    \newcounter{diceNo}
    \newcommand\dicef[2][]{%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      #1%
    
      \setcounter{diceNo}{#2}%
    
      \ifnum\value{diceNo}=12%
        \epsdice[black]{6}%
        \epsdice{6}%
    
      \else%
    
        \ifnum\value{diceNo}>0%
          \whileboolexpr{%
            test {\ifnumcomp{\value{diceNo}}{>}{6}}%
            }{%
              \addtocounter{diceNo}{-5}%
              \epsdice{5}%
            }%
          \epsdice[black]{\value{diceNo}}%
        \else%
          \arabic{diceNo}%
        \fi%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcommand\twoDice[1]{%
      \setcounter{diceNo}{#1}%
      \ifnum\value{diceNo}<2%
        \setcounter{diceNo}{2}%
      \fi%
      \ifcase\value{diceNo}%
        diceError 0%
      \or%
        diceError 1%
      \or%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
        \epsdice{1}~\epsdice[black]{1}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \or%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
        \epsdice{1}~\epsdice[black]{2}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \or%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
        \epsdice{1}~\epsdice[black]{3}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \or%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
        \epsdice{1}~\epsdice[black]{4}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \or%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
        \epsdice{1}~\epsdice[black]{5}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \or%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
        \epsdice{1}~\epsdice[black]{6}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \or%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
        \epsdice{2}~\epsdice[black]{6}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \or%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
        \epsdice{3}~\epsdice[black]{6}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \or%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
        \epsdice{4}~\epsdice[black]{6}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \or%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
        \epsdice{5}~\epsdice[black]{6}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \or%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
        \epsdice{6}~\epsdice[black]{6}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \else
        diceError%
      \fi%
    }
    
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcounter{diceNo2}
    \newcommand\rollDice[1]{%
      \setcounter{track}{#1}%
      \setcounter{diceNo}{1}%
      \setcounter{diceNo2}{1}%
      \ifnum\value{track}>7%
        \setcounter{diceNo2}{6}%
      \fi%
      \addtocounter{track}{-\value{diceNo2}}%
      \setcounter{diceNo}{\value{track}}%
      \epsdice[black]{\arabic{diceNo}} \epsdice{\arabic{diceNo2}}
      }
    
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcounter{dlist}
    
    \newenvironment{dlist}%
    
      {\raggedright\begin{list}{\Large\dicef{\value{dlist}}}{\usecounter{dlist}}}%
    
      {\end{list}\null}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newenvironment{dlistDouble}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      {\raggedright%
      \begin{list}%
      {\ifnum\value{dlist}=1%
        \stepcounter{dlist}%
      \fi%
      \makebox[0pt][c]{\raisebox{-1em}{\qquad\textcolor{\pageSideColor}{\arabic{dlist}}}}%
      \Large\twoDice{\value{dlist}}}%
      {\usecounter{dlist}}}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      {\end{list}\null}%
    
    
    \newcounter{blingNo}
    \setcounter{blingNo}{0}
    
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    % Define the 'ornamentedbox' environment
    
    % Wiggly Borders
    \tikzset{
      use path for main/.code={%
        \tikz@addmode{%
          \expandafter\pgfsyssoftpath@setcurrentpath\csname tikz@intersect@path@name@#1\endcsname
        }%
      },
      use path for actions/.code={%
        \expandafter\def\expandafter\tikz@preactions\expandafter{\tikz@preactions\expandafter\let\expandafter\tikz@actions@path\csname tikz@intersect@path@name@#1\endcsname}%
      },
      use path/.style={%
        use path for main=#1,
        use path for actions=#1,
      }
    }
    
    
    \tikzset{ornamented frame inner/.style={color=\pageSideColor,
    
    Malin Freeborn's avatar
    Malin Freeborn committed
                                            line width=2pt},
    
             ornamented frame outer/.style={color=black,
    
    Malin Freeborn's avatar
    Malin Freeborn committed
                                            line width=3pt}}
    
    \tcbsubskin{ornamented}{empty}{
      skin first=ornamented,  skin last=ornamented,
      title engine=standard,
      colbacktitle=white,
    
      colframe={\pageSideColor},
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      frame code={
        % Account for the line widths in order not to draw beyond the bounding
        % box---except for a few very small details for which this is intentional.
        \coordinate (north west) at ([shift={(1.5pt,-1.5pt)}]frame.north west);
        \coordinate (north east) at ([shift={(-1.5pt,-1.5pt)}]frame.north east);
        \coordinate (south east) at ([shift={(-1.5pt,1.5pt)}]frame.south east);
        \coordinate (south west) at ([shift={(1.5pt,1.5pt)}]frame.south west);
        %
        \foreach \xoffset/\point in {34pt/north west, -34pt/north east,
                                      34pt/south west, -34pt/south east} {
    
          \fill[color=\pageOppositeColor]
    
    Malin Freeborn's avatar
    Malin Freeborn committed
            ([xshift=\xoffset]\point) circle[radius=2.5pt];
        }
        %
        \path[name path=ornament 1]
                                     ([yshift=-4pt]north west)
          [rounded corners=0.5pt] -- ++(23pt,0)
          [rounded corners=2pt]   -- ++(3pt,-4pt)
                                  -- ([shift={(-26pt,-8pt)}]north east)
          [rounded corners=0.5pt] -- ++(3pt,4pt)
          [rounded corners=4pt]   -- ([yshift=-4pt]north east)
                                  -- ([yshift=4pt]south east)
          [rounded corners=0.5pt] -- ++(-23pt,0)
          [rounded corners=2pt]   -- ++(-3pt,4pt)
                                  -- ([shift={(26pt,8pt)}]south west)
          [rounded corners=0.5pt] -- ++(-3pt,-4pt)
          [rounded corners=4pt]   -- ([yshift=4pt]south west)
                                  -- cycle;
        %
        \path[rounded corners=0.5pt, name path=ornament 2]
                                     ([yshift=-20pt]north west)
                                  -- ++(-4pt,3pt)
                                  -- ++(0,4pt)
                   to[out=0, in=-90] ([shift={(8pt,0pt)}]north west)
                                  -- ([shift={(34pt,0pt)}]north west)
                                  -- ([shift={(-8pt,0pt)}]north east)
                 to[out=-90, in=180] ([shift={(4pt,-13pt)}]north east)
                                  -- ++(0,-4pt)
                                  -- ++(-4pt,-3pt)
                                  -- ([yshift=20pt]south east)
                                  -- ++(4pt,-3pt)
                                  -- ++(0,-4pt)
                  to[out=180, in=90] ([shift={(-8pt,0pt)}]south east)
                                  -- ([shift={(8pt,0pt)}]south west)
                    to[out=90, in=0] ([shift={(-4pt,13pt)}]south west)
                                  -- ++(0,4pt)
                                  -- ++(4pt,3pt)
                                  -- cycle;
        %
        \draw[ornamented frame outer, use path=ornament 1];
        \draw[ornamented frame outer, use path=ornament 2];
        \draw[ornamented frame inner, use path=ornament 1];
        \draw[ornamented frame inner, use path=ornament 2];
      }
    }
    
    % These parameters---especially those related to geometry---are better located
    % here in a style than in the subskin definition (see the Subskins section of
    % the tcolorbox manual).
    
    \tcbset{ornamented/.style={skin=ornamented,
      toptitle=14.5pt,
      top=15pt,
      bottom=9.5pt,
    
      fontupper={\normalsize},
    
      coltitle=black,
      }
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    }
    
    % Convenient style to use with a tcolorbox preceded by text (or anything),
    % when one wants to prevent any page break before the tcolorbox.
    \tcbset{skip and no break/.style={
      before={\par\nopagebreak\vspace{2ex}\noindent}}
    }
    
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    % Style suitable for an "on line" (in the middle of a paragraph)
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    % 'ornamentedbox'.
    \tcbset{my on line/.style={
      capture=hbox, tcbox raise base, top=14pt, bottom=14pt,
      before={\kern 5pt}, after={\kern 5pt}}
    }
    
    %%%%% TColorBox Basic Setup %%%%%
    
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \tcbset{
      enhanced,
      left=3pt,
      right=3pt,
      code={\rowcolors{2}{}{gray!10}},
      before upper={\parindent15pt},
      fonttitle=\bfseries\scshape,
      coltitle=black,
      attach boxed title to top center={
        yshift=-0.25mm-\tcboxedtitleheight/2,
        yshifttext=-2mm-\tcboxedtitleheight/2
        },
      boxed title style={
        frame code={
          \path[draw=black, tcb fill frame] ([xshift=-4mm]frame.west)
          -- (frame.north west) -- (frame.north east) -- ([xshift=4mm]frame.east)
          -- (frame.south east) -- (frame.south west) -- cycle;
        },
        interior code={
          \path[draw=black, tcb fill interior] ([xshift=-2mm]interior.west)
          -- (interior.north west) -- (interior.north east)
          -- ([xshift=2mm]interior.east) -- (interior.south east) -- (interior.south west)
          -- cycle;
        }
      },
    
    \newtcolorbox{boxtext}[1][]{
      colback=white,
    
      before={\vspace{.5em}\noindent},
    
      fonttitle={\scshape #1},
    
      before upper={\parindent15pt\noindent},
    
      after upper={\iftoggle{verbose}{}{\par What do you do?}},
    
    \newcommand{\sidebox}[2][23]{
    
    Malin Freeborn's avatar
    Malin Freeborn committed
        \needspace{4em}
    
        \begin{wrapfigure}{R}{.#1\textwidth} 
        #2
        \end{wrapfigure}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    %%%%% Header Formatting %%%%%
    
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    % Chapter Heading Color
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \colorlet{chapnumcol}{black!100}
    
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcommand{\headingtype}{Chapter}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    
    \newcommand\outline[2][7]{\contour[#1]{black}{\textcolor{white}{#2}}}
    \contourlength{0.1em}
    
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    %%%%% Section Formatting %%%%%
    
    
    \newcommand{\frontpage}[2][\expandafter\MakeUppercase \jobname]{
    
      \frontmatter
    
      \pagenumbering{gobble}
    
      \begin{titlepage}
        \centering
    
        \includesvg[width=.2\textwidth]{config/logo}
        \par
        \vspace{-2em}
    
        {\Huge\scshape\outline{#1}\par}
    
        \vspace{2em}
    
        {\large\scshape \underline{#2}\par}
        \tableofcontents
        \bigLine
    
        \flushright
    
        \vfill\null
    
        {\footnotesize \textcolor{\pageSideColor}{Printed \today, or \showCycle~\Roman{fenestraDay}}\par}
    
      \end{titlepage}
      \cleardoublepage
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \frontmatter
    
    \newcommand\startappendix{
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \backmatter
    
      \appendix
      \renewcommand{\headingtype}{APPENDIX}
    
      \renewcommand\showChapter{\Alph{chapter}}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \cleardoublepage
      \chapter{Appendix}
      \renewcommand{\npcsymbol}{\quad\scshape Appendix\quad}
    
    \newcommand\shiftColours{
    
      \ifnum\value{pageDarkness}<80
        \addtocounter{pageDarkness}{7}
    
        \ifnum\value{pageDarkness}>30
          \setcounter{pageAlt}{0}
        \fi
    
      \else
    
        \addtocounter{pageDarkness}{-60}
        \setcounter{pageAlt}{100}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcounter{adf}
    \setcounter{adf}{0}
    
    \newcommand\flourish{%
    
      \ifnum\value{adf}>16%
        \addtocounter{adf}{-16}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \fi%
      \ifcase\value{adf}%
      \adforn{32}%
      \or%
      \adforn{27}%
      \or%
      \adforn{3}%
      \or%
    
      \adforn{25}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \or%
    
      \adforn{5}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \or%
    
      \adforn{34}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \or%
      \adforn{68}%
      \or%
    
      \adforn{9}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \or%
      \adforn{73}%
      \or%
    
      \adforn{11}%
      \or%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \adforn{44}%
      \or%
    
      \adforn{6}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \or%
    
      \adforn{40}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \or%
    
      \adforn{63}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \or%
    
      \adforn{67}%
      \or%
      \adforn{52}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \else%
    
      \adforn{55}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \fi%
      \stepcounter{adf}%
    }
    
    
    \newcommand\showChapter{\Roman{chapter}}
    
    
    \titleformat{\chapter}[display]
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    {\bfseries
    \titleFont
    }
    
    {%
      \shiftColours
    
      \hspace*{-1.5em}
    
      \begin{tikzpicture}
        \node[minimum width=\linewidth+3em, text=\pageOppositeColor, fill=\pageSideColor, inner sep=1, outer sep=0, anchor=south] (rectinit) {\Huge \headingtype};
       \node[minimum width=.75\textwidth, text=white, inner sep=3, outer sep=0, anchor=south west, text width=.75\textwidth, align=right] at (rectinit.south west) (chapname) {};
        \node[minimum width=.25\textwidth, inner sep=-5, outer sep=0, anchor=south west, text width=.25\textwidth, align=left] at (chapname.south east) {\chapnumfont\textcolor{chapnumcol}{\showChapter}};
      \end{tikzpicture}
    }
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    {0pt}
    
    {\Huge#1}
    
    \titleformat{\section}%
    
      {\needspace{16em}%
    
      \textcolor{\pageSideColor}{\large\raisebox{-4pt}{\Large\hspace{-0.2em}\flourish}\titlerule}%
    
      \center%
    
      \huge%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \titleFont
      }%
    
      {\Roman{section}}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      {1em}%
    
      {#1}%
    
      [\textcolor{\pageSideColor}{\large\titlerule\raisebox{-4pt}{\Large\hspace{-0.2em}\flourish}}%
      \setcounter{list}{0}]%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \renewcommand*{\thesection}{\arabic{section}}
    
    
    \titleformat{\subsection}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      {\titleFont%
    
      \needspace{4\baselineskip}%
    
      \LARGE}%
    
      {\thesubsection}%
      {1em}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      {\center#1}%
    
      [\textcolor{\pageSideColor}{\titlerule}]
    
    
    \titleformat{\subsubsection}[wrap]
    
    {\needspace{3em}\filright%
    \titleFont%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \large\centering}
    
    {}{.5em}{#1}
    
    
    \titlespacing{\subsubsection}
    
    {9pc}{1.5ex plus .1ex minus .2ex}{1pc}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    
    %%%%% Character Sheet Tracker
    
    
        \newcounter{track}
        \setcounter{track}{18}
    
        \newcommand{\tracker}{%
        \center\noindent%
          \iftoggle{examplecharacter}{%
            \iftoggle{genExamples}{}{%
              \ifnum\value{track}=\value{ap}%
                $\Rightarrow$ %
              \fi%
            }}{}%
            \arabic{track}%
            \addtocounter{track}{-1}%
            \vspace{.54cm}
    
    \newcommand\bigLine{%
    
      \textcolor{\pageSideColor}{\ifodd\value{page}\else\raisebox{-3pt}{\Large\hspace{0.1em}\flourish}\fi\hrulefill\ifodd\value{page}\raisebox{-3pt}{\Large\hspace{-0.1em}\flourish}\fi}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \par%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    %%%%% NPC Names
    
    \newcommand{\name}{}
    
    \newcommand{\NPCdescription}{}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcommand{\currentQuote}{}
    
    \newcommand\npcQuote[1]{\global\renewcommand\currentQuote{#1}}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcommand{\mannerism}{}
    
    \newcommand{\npcGoal}{}
    
    \newcommand{\npcsymbol}{\adfast{\value{r4}}}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcommand{\npc}[2]{%
      \global\def\name{#2}%
      \renewcommand{\npcsymbol}{#1}%
    }
    
    
    \newcommand{\NPC}[5]{%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \global\def\name{#2}%
    
      \renewcommand{\npcsymbol}{#1}%
      \settoggle{personality}{true}%
      \renewcommand{\NPCdescription}{#3}%
      \renewcommand{\mannerism}{#4}%
      \renewcommand{\npcGoal}{#5}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    }
    
    %%%%%%%%%%%%%%%%%%%% TOGGLES %%%%%%%%%%%%%%%%%%%%
    
    \newtoggle{verbose}
    \settoggle{verbose}{true}
    \newtoggle{personality}
    \settoggle{personality}{false}
    
    
    \setcounter{tocdepth}{1}
    \setcounter{secnumdepth}{1}
    
    
    %%%%%%%%%%%%%%%%%%%% RANDOM NUMBERS %%%%%%%%%%%%%%%%%%%%
    
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcounter{r4}
    \setcounter{r4}{\day}
    \addtocounter{r4}{1}
    
      \whileboolexpr{
        test {\ifnumcomp{\value{r4}}{>}{4}}
      }
      {\addtocounter{r4}{-3}}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    
    \newcounter{r2}
    \setcounter{r2}{\value{r4}}
    \newcounter{r2b}
    
      \setcounter{r2b}{\value{r2}}
      \addtocounter{r2b}{-1}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcounter{r2c}
    
      \setcounter{r2c}{2}
    \newcounter{r2d}
      \setcounter{r2d}{1}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcounter{r3}
    \setcounter{r3}{\month}
    
      \divide\value{r3} by 4
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcounter{r3b}
    
      \setcounter{r3b}{\value{r4}}
      \addtocounter{r3b}{-1}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcounter{r3c}
    
      \setcounter{r3c}{1}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcounter{r4b}
    
      \setcounter{r4b}{\day}
    
      \divide\value{r4b} by 7
      \stepcounter{r4b}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcounter{rn4tn1}
      \setcounter{rn4tn1}{-3}
    
    \newcounter{rn1t0}
      \setcounter{rn1t0}{-1}
    \newcounter{r0t1}
      \setcounter{r0t1}{0}
    \newcounter{r2t3}
      \setcounter{r2t3}{2}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcounter{r2t4}
      \setcounter{r2t4}{2}
    
    \newcounter{r3t4}
      \setcounter{r3t4}{3}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcounter{rn1t2}
      \setcounter{rn1t2}{0}
    
    \newcounter{rn3t3}
      \setcounter{rn3t3}{3}
    \newcounter{r4t5}
      \setcounter{r4t5}{4}
    
    \newcounter{r4t6}
      \setcounter{r4t6}{4}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcounter{r12}
    \setcounter{r12}{\month}
    \newcounter{enc}
    \newcounter{list}
    
    \newcounter{age}
    \setcounter{age}{1}
    \newcounter{gold}
    \setcounter{gold}{\day}
    \setcounter{enc}{0}
    
    \newcounter{noAppearing}
      \setcounter{noAppearing}{1}
    
    \newcommand{\randomtwo}{%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \ifnum\value{r2}>1%
        \setcounter{r2}{1}%
      \else%
        \stepcounter{r2}%
      \fi%
      \setcounter{enc}{\value{r2}}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcommand{\randomtwoB}{%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \ifodd\value{r3}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
        \setcounter{r2b}{1}%
      \else%
        \setcounter{r2b}{2}%
      \fi%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcommand{\randomtwoC}{%
    
      \ifnum\value{r2c}>1%
    
        \setcounter{r2c}{1}%
      \else%
        \stepcounter{r2c}%
    
    \newcommand{\randomtwoD}{%
      \ifnum\value{r2d}>1%
      \setcounter{r2d}{1}\else%
      \stepcounter{r2d}%
      \fi%
    }
    
    
    \newcommand{\randomthree}{%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \ifnum\value{r3}>2%
        \setcounter{r3}{1}%
      \fi%
      \ifnum\value{r3}<1%
        \setcounter{r3}{2}%
      \fi%
      \stepcounter{r3}%
    
      \setcounter{age}{\value{r3}}%
    }
    
    \newcommand{\randomthreeB}{%
    
      \ifnum\value{r3b}>2%
        \setcounter{r3b}{1}%
      \fi%
      \ifodd\value{r3}%