Files
the-sourdough-framework/book/sourdough.sty
cedounet 2b90763107 Make each chapter introduction stand out (#179)
* Add bibliography to the ToC

* Add a list of tables at the end of the document

It needed shorter description that would fit.

* Add list of figures

* Add table of figures

* Fix a typo in short figure description

* Make each chapter introduction stand out

Not written for each chapter yet, but checking if that is something we
want.

* Increase numwidth in list of figures

Prevents over-run of figure number and text

* Use semibold in chapters intro

Looks like a good compromise for now.

* Add comments

* Add color coding to flow charts

This will hopefully allow easier reading by identifying start and end
point more easily
2023-08-18 15:30:51 +02:00

276 lines
9.3 KiB
TeX

\ProvidesPackage{sourdough}
\usepackage{blindtext}
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{longtable}
\usepackage{tocbasic}
\usepackage{chemformula}
\usepackage{chemfig}
\usepackage{booktabs}
\usepackage{makecell}
\usepackage[mode=match, reset-text-family=false]{siunitx}
\usepackage{fontspec}
\usepackage{calc}
\usepackage[font={sffamily, sbseries}]{quoting}
\DeclareTOCStyleEntry[numwidth=3em]{tocline}{figure}
% For tables
\renewcommand\theadfont{\bfseries}
\definecolor{codeblue}{RGB}{69, 161, 248}
\definecolor{codeblack}{RGB}{40, 40, 40}
\definecolor{maingray}{HTML}{F8F8F8}
\definecolor{hlocre}{HTML}{E5B874}
\definecolor{hlorange}{HTML}{EC7850}
\definecolor{hlyellow}{HTML}{FAE69E}
\definecolor{pinkpic}{RGB}{246, 183, 194}
\definecolor{redpic}{RGB}{232, 72, 71}
\definecolor{yellowpic}{RGB}{246, 235, 51}
\tikzstyle{every picture}+=[font=\small\sffamily]
\usetikzlibrary{shapes,arrows}
\tikzstyle{decision} = [diamond, draw, fill=codeblack, text=white,
text width=4.5em, text badly centered, node distance=3cm, inner sep=0pt]
\tikzstyle{block} = [rectangle, draw, fill=codeblue, text=white,
text width=5em, text centered, rounded corners, minimum height=4em]
\tikzstyle{decision_start} = [diamond, draw, fill=pinkpic, text=black,
text width=4.5em, text badly centered, node distance=3cm, inner sep=0pt]
\tikzstyle{start} = [rectangle, draw, fill=pinkpic, text=black,
text width=5em, text centered, rounded corners, minimum height=4em]
\tikzstyle{success} = [rectangle, draw, fill=yellowpic, text=black,
text width=5em, text centered, rounded corners, minimum height=4em]
\tikzstyle{fail} = [rectangle, draw, fill=redpic, text=black,
text width=5em, text centered, rounded corners, minimum height=4em]
\tikzstyle{line} = [draw, -latex']
% Fonts
\defaultfontfeatures{Scale=MatchLowercase, Ligatures=TeX}
% Define Semi-bold
\DeclareRobustCommand\sbseries{\fontseries{sb}\selectfont}
% Fonts for accessibility
\ifdefined\isaccessible
\setmainfont{Open Sans}[
Scale=MatchLowercase]
\else
\setmainfont{TeX Gyre Pagella}[Scale=1.0] % Or Palatino Linotype, etc.
% TODO not available on github CI
% \setmonofont{Andale Mono}[Scale=MatchLowercase]
\fi
% Opens Sans in both case..
\setsansfont{Open Sans}[
Scale=MatchLowercase,
FontFace = {sb}{it}{* Semibold Italic},
FontFace = {sb}{n}{*-semibold}]
% Kerning in footnotes
\usepackage{fnpct}
% References
\usepackage[backend=biber]{biblatex}
\addbibresource{references.bib}
% Clickable links in the table of contents
\usepackage[ocgcolorlinks]{hyperref}
\hypersetup{%
linktoc=all,
allcolors=codeblue
}
% Folders where to search for images
\graphicspath{
{images/}
{troubleshooting/}
{sourdough-starter/}
{troubleshooting/crumb-structures/}
{history/}
{images/external/}
{baking/}
{wheat-sourdough/}
{wheat-sourdough/shaping/}
{non-wheat-sourdough/}
}
% Caption and figure size below images
\usepackage{caption}
\captionsetup[figure]{font=footnotesize}
\DeclareSIUnit\degF{\text{°}F}
%-----------------------------------------------------------------------------
% KAO CHAPTER HEADING STYLES
%-----------------------------------------------------------------------------
\newlength{\hscale}
\newlength{\vscale}
\newlength{\mtocshift}
% By default, the scales are set to work for a4paper
\setlength{\hscale}{1mm}
\setlength{\vscale}{1mm}
\newif\ifwidelayout%
\def\IfWideLayout{%
\ifwidelayout%
\expandafter\@firstoftwo%
\else%
\expandafter\@secondoftwo%
\fi%
}
% Command to easily switch between chapter styles
\DeclareDocumentCommand{\setchapterstyle}{m}{%
\ifthenelse{\equal{plain}{#1}}{\chapterstyleplain}{}
\ifthenelse{\equal{bar}{#1}}{\chapterstylebar}{}
\ifthenelse{\equal{lines}{#1}}{\chapterstylelines}{}
\ifthenelse{\equal{kao}{#1}}{\chapterstylekao}{}
}
% The default definition in KOMA script
\DeclareDocumentCommand{\chapterstyleplain}{}{%
\renewcommand{\chapterlinesformat}[3]{%
\@hangfrom{##2}{##3}}
\renewcommand*{\chapterformat}{%
\mbox{\chapappifchapterprefix{\nobreakspace}\thechapter%
\autodot\IfUsePrefixLine{}{\enskip}}}
\RedeclareSectionCommand[beforeskip=0cm,afterskip=10\vscale]{chapter}
\setlength{\mtocshift}{-1\vscale}
}
% Gray bar
\DeclareDocumentCommand{\chapterstylebar}{}{%
\renewcommand*{\chapterformat}{%
\mbox{\chapappifchapterprefix{\nobreakspace}\thechapter%
\autodot\IfUsePrefixLine{}{\enskip}}%
}
\renewcommand{\chapterlinesformat}[3]{%
\begin{tikzpicture}[remember picture, overlay]
\node[
anchor=south west,
xshift=\dimexpr - \hoffset - \oddsidemargin - 1in -1mm,%-30\hscale,
yshift=4.3mm,
rectangle,
fill=gray!20!white,
fill opacity=0.8,
inner ysep=5\vscale,
inner xsep=\dimexpr \hoffset + \oddsidemargin + 1in,%30\hscale,
text opacity=1,
text width=\paperwidth-40\hscale,
]{\@hangfrom{##2}{##3}};
\end{tikzpicture}
}
\RedeclareSectionCommand[beforeskip=-55\vscale,afterskip=6\vscale]{chapter}
\setlength{\mtocshift}{-1\vscale}
}
% Lines
\renewcommand{\hrulefill}[1][0.4pt]{%
\leavevmode\leaders\hrule height #1\hfill\kern\z@%
}
\DeclareDocumentCommand{\chapterstylelines}{}{%
\renewcommand*{\chapterformat}{%
\chapappifchapterprefix{\nobreakspace}\scalebox{3.5}{\thechapter\autodot}%
}%
\renewcommand\chapterlinesformat[3]{%
%\vspace*{-1cm}%
\leavevmode%
\makebox[0pt][l]{%
\makebox[\textwidth][l]{\hrulefill[1pt]##2}%\hfill%\par%\bigskip
\makebox[\marginparsep][l]{}%
\makebox[\marginparwidth][l]{}%
}\\
%\vspace{.5cm}
\makebox[0pt][l]{%
\makebox[\textwidth][l]{##3}%
\makebox[\marginparsep][l]{}%
\makebox[\marginparwidth][l]{}%
}\\
\makebox[0pt][l]{%
\makebox[\textwidth+\marginparsep+\marginparwidth][l]{\hrulefill[1.1pt]}%
}%
\RedeclareSectionCommand[beforeskip=0cm,afterskip=10\vscale]{chapter}
\setlength{\mtocshift}{-1\vscale}%
}
}
% The Kao style
\DeclareDocumentCommand{\chapterstylekao}{}{%
\IfWideLayout{%
\renewcommand*{\chapterformat}{%
\mbox{\chapappifchapterprefix{\nobreakspace}\scalebox{2.85}{\thechapter\autodot}}%
}%
\renewcommand\chapterlinesformat[3]{%
\vspace{3.5\vscale}%
\if@twoside%
\Ifthispageodd{%
\smash{\makebox[0pt][l]{%
\parbox[b]{\textwidth - 6.2\hscale}{\flushright{##3}}%
\makebox[6.2\hscale][c]{\rule[-2\vscale]{1pt}{27.4\vscale+\f@size mm}}%
\parbox[b]{\marginparwidth}{##2}%
}}%
}{
\smash{\makebox[\textwidth + 6.2\hscale][r]{%
\parbox[b]{47.7\hscale + 6.2\hscale}{\flushright{##2}}%
\makebox[6.2\hscale][c]{\rule[-2\vscale]{1pt}{27.4\vscale+\f@size mm}}%
\parbox[b]{\textwidth}{\flushleft{##3}}%
}}%
}
\else%
\smash{\makebox[0pt][l]{%
\parbox[b]{\textwidth - 6.2\hscale}{\flushright{##3}}%
\makebox[6.2\hscale][c]{\rule[-2\vscale]{1pt}{27.4\vscale+\f@size mm}}%
\parbox[b]{\marginparwidth}{##2}%
}}%
\fi%
}%
}{%
\renewcommand*{\chapterformat}{%
\mbox{\chapappifchapterprefix{\nobreakspace}\scalebox{2.85}{\thechapter\autodot}}%
}%
\renewcommand\chapterlinesformat[3]{%
\vspace{3.5\vscale}%
\if@twoside%
\Ifthispageodd{%
\smash{\makebox[0pt][l]{%
\parbox[b]{\textwidth}{\flushright{##3}}%
\makebox[\marginparsep][c]{\rule[-2\vscale]{1pt}{27.4\vscale+\f@size mm}}%
\parbox[b]{\marginparwidth}{##2}%
}}%
}{
\smash{\makebox[\textwidth][r]{%
\parbox[b]{\marginparwidth}{\flushright{##2}}%
\makebox[\marginparsep][c]{\rule[-2\vscale]{1pt}{27.4\vscale+\f@size mm}}%
\parbox[b]{\textwidth}{\flushleft{##3}}%
}}%
}
\else%
\smash{\makebox[0pt][l]{%
\parbox[b]{\textwidth}{\flushright{##3}}%
\makebox[\marginparsep][c]{\rule[-2\vscale]{1pt}{27.4\vscale+\f@size mm}}%
\parbox[b]{\marginparwidth}{##2}%
}}%
\fi%
}%
}%
\RedeclareSectionCommand[beforeskip=0cm,afterskip=10\vscale]{chapter}%
\setlength{\mtocshift}{-3.5\vscale}%
}
% Takes as input the image path and optionally the "beforeskip"
\DeclareDocumentCommand{\setchapterimage}{O{55\vscale} m}{%
\setchapterpreamble[o]{%
\vspace*{-27\vscale}\hspace*{\dimexpr - \hoffset - \oddsidemargin - 1in}%
\includegraphics[width=\paperwidth,height=#1+27\vscale,keepaspectratio=false]{#2}%
}%
\chapterstylebar%
% beforeskip=-(figure_height-top_margin)
\RedeclareSectionCommand[beforeskip=-#1, afterskip=6\vscale]{chapter}%
\setlength{\mtocshift}{0cm}%
}
% By default start with the lines style
\setchapterstyle{lines}