Skip to content

Instantly share code, notes, and snippets.

@sandhose
Created August 18, 2020 09:49
Show Gist options
  • Save sandhose/8a209b7e5acab5e09a055ac5d9e5788c to your computer and use it in GitHub Desktop.
Save sandhose/8a209b7e5acab5e09a055ac5d9e5788c to your computer and use it in GitHub Desktop.
% Tikz lets us draw anything
\usepackage{tikz}
\usetikzlibrary{calc} % Coordinate calculation in tikz
% Allows drawing in the background
\pgfdeclarelayer{bg}
\pgfsetlayers{bg,main}
% Allows customizing the headings
\usepackage[explicit]{titlesec}
\newfontfamily\rsfamily{Roboto Slab}
\newfontfamily\sspfamily{Source Sans Pro}
% Define some colors
\definecolor{csyellow}{HTML}{FFE66D}
\definecolor{csteal}{HTML}{4ECDC4}
\definecolor{csred}{HTML}{FF6B6B}
\definecolor{csdarkgreen}{HTML}{1A535C}
\definecolor{csdark}{HTML}{0A1F22}
\definecolor{cslight}{HTML}{F7FFF7}
% Fancy chapter headings
\titleformat{\chapter}[display]
{\normalfont\rsfamily\Huge\fontseries{m}}
{}
{\dimexpr-\oddsidemargin-\hoffset-1in}
{%
\begin{tikzpicture}[]
\draw (0,0) +(0,0) node[anchor=west](head){\thechapter{}.~#1};
\begin{pgfonlayer}{bg}
\fill [csyellow] ($(head.south west)+(-0.1,0.05)$) rectangle ($(head.south east)+(-0.4,0.37)$);
\end{pgfonlayer}
\end{tikzpicture}%
}
% Less fancy headings (but with custom font)
\titleformat{\section}
{\normalfont\rsfamily\Large\fontseries{m}}
{\thesection.}{1em}{#1}
\titleformat{\subsection}
{\normalfont\rsfamily\large\fontseries{m}}
{\thesubsection.}{1em}{#1}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment