Skip to content

Instantly share code, notes, and snippets.

@aixnr
Last active March 29, 2021 23:36
Show Gist options
  • Save aixnr/17743d34abf9512ba037d358051ec929 to your computer and use it in GitHub Desktop.
Save aixnr/17743d34abf9512ba037d358051ec929 to your computer and use it in GitHub Desktop.
Aizan's Custom LaTeX Commons
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{aizancommons}[2019/09/21 Aizan's Commons LaTeX package]
% Package declarations
% -------------------------------------------------------------------
\RequirePackage[utf8]{inputenc}
\RequirePackage[letterpaper, left=0.7in, right=0.7in, top=0.5in, bottom=0.5in]{geometry}
\RequirePackage{parskip} % disable the new paragraph indent
\RequirePackage{enumitem} % somehow fixes the linespacing for numbering
\RequirePackage[dvipsnames]{xcolor} % enable color
\RequirePackage{gensymb} % for generic degree commands
\RequirePackage{amssymb} % more fancy arrows
\RequirePackage{graphicx} % for adding images
\RequirePackage{float} % to properly float image without causing a war
\RequirePackage[font=small,skip=0pt]{caption} % required to better style the caption
\RequirePackage{hyperref} % to allow hyperlink in document
\RequirePackage[T1]{fontenc} % enable a proper font encoding (8 bit, 256 glyphs)
\RequirePackage{upgreek} % for using upright greek letters
\RequirePackage{amsmath} % better math
\RequirePackage[default]{sourcesanspro} % default font is Source Sans Pro
% Package declarations (extras)
% -------------------------------------------------------------------
\RequirePackage{fontspec}
\RequirePackage{listings}
\RequirePackage{natbib}
% Overriding defaults
% -------------------------------------------------------------------
\renewcommand{\baselinestretch}{1.3} % set line-spacing
\pagenumbering{gobble} % turn off page numbering
\graphicspath{{./images/}} % define the path for images
\renewcommand\textbullet{\ensuremath{\bullet}} % stop nagging about font size for bullet point
\captionsetup[figure]{font=small,skip=5pt} % required to better style the caption
\hypersetup{colorlinks=true, linkcolor=blue, urlcolor=blue, citecolor=blue}
\newcommand{\bi}{\begin{itemize}[noitemsep, topsep=0pt]} % itemize with noitemsep
\newcommand{\ei}{\end{itemize}}
\newcommand{\be}{\begin{enumerate}[noitemsep, topsep=0pt]} % enumerate with noitemsep
\newcommand{\ee}{\end{enumerate}}
\setmonofont{Courier New}
% Custom shortcuts
% -------------------------------------------------------------------
\newcommand{\tred}{\textcolor{red}}
\newcommand{\tpurple}{\textcolor{Fuchsia}}
\newcommand{\tcyan}{\textcolor{cyan}}
\newcommand{\tsup}{\textsuperscript}
\newcommand{\tsub}{\textsubscript}
\newcommand{\pUpDown}{$\downharpoonleft$$\upharpoonright$}
\newcommand{\minititle}[1]{\textbf{\textit{#1}}\vspace{-2mm}}
% Inline syntax highlighting
% -------------------------------------------------------------------
\definecolor{wolf}{RGB}{246, 246, 246}
\newcommand{\mono}[1]{\colorbox{wolf}
{\textcolor{Maroon}
{\texttt{#1}}
}
}
% Colorboxes
% -------------------------------------------------------------------
\newcommand{\boxorange}[1]{\colorbox{orange}{\textcolor{white}{\textbf{#1}}}}
\newcommand{\boxred}[1]{\colorbox{red}{\textcolor{white}{\textbf{#1}}}}
\newcommand{\boxblack}[1]{\colorbox{black}{\textcolor{white}{\textbf{#1}}}}
\newcommand{\boxblue}[1]{\colorbox{cyan}{\textcolor{white}{\textbf{#1}}}}
% Simplified Units & Symbols
% -------------------------------------------------------------------
\newcommand{\ul}{$\upmu$l} % define microliter
\newcommand{\ug}{$\upmu$g} % define microgram
\newcommand{\uM}{$\upmu$M} % define micromolar
\newcommand{\um}{$\upmu$m} % define micron
\newcommand{\dg}{$\degree$} % define degree
\newcommand{\X}{$\times$} % define multiplication
% If Inter font is absence, go to sfdefault
% -------------------------------------------------------------------
\DeclareOption{sfd}{
\renewcommand{\familydefault}{\sfdefault} % uses Source Sans Pro
\newcommand{\sbseries}{\bfseries} % map bfseries to sbseries
}
% Use custom Inter font by Rasmus Andersson with option, requires XeTeX
% -------------------------------------------------------------------
\DeclareOption{inter}{
% https://github.com/rsms/inter
% https://tex.stackexchange.com/questions/404237/xelatex-and-font-weight
\setmainfont{Inter}
\setsansfont{Inter}[
BoldFont= Inter Bold,
FontFace={l}{n}{Font=* Light BETA},
FontFace={sb}{n}{Font=* Semi Bold},
]
% set command for using custom fonts
\DeclareRobustCommand{\lseries}{\fontseries{l}\selectfont}
\DeclareRobustCommand{\sbseries}{\fontseries{sb}\selectfont}
}
% Use syntax highlighting with option
% -------------------------------------------------------------------
\DeclareOption{syn}{
\definecolor{codegreen}{rgb}{0,0.6,0}
\definecolor{codegray}{rgb}{0.5,0.5,0.5}
\definecolor{codepurple}{rgb}{0.58,0,0.82}
\definecolor{backcolour}{rgb}{0.95,0.95,0.92}
\lstdefinestyle{standard}{
backgroundcolor=\color{backcolour},
commentstyle=\color{codegreen},
keywordstyle=\color{magenta},
numberstyle=\tiny\color{codegray},
stringstyle=\color{codepurple},
basicstyle=\ttfamily\small,
breakatwhitespace=false,
breaklines=true,
captionpos=b,
keepspaces=true,
showspaces=false,
showstringspaces=false,
showtabs=false,
tabsize=2
}
\lstset{style=standard}
}
% Activate natbib with option
% -------------------------------------------------------------------
\DeclareOption{citer}{
\bibliographystyle{abbrvnat}
\setcitestyle{authoryear}
\renewcommand{\bibsection}{}
}
% Execute default
% -------------------------------------------------------------------
\ExecuteOptions{sfd}
\ProcessOptions\relax
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment