Skip to content

Instantly share code, notes, and snippets.

@willwm
Last active February 7, 2022 15:48
Show Gist options
  • Save willwm/cecb5eb83cf943f664db29dfd7f9ef84 to your computer and use it in GitHub Desktop.
Save willwm/cecb5eb83cf943f664db29dfd7f9ef84 to your computer and use it in GitHub Desktop.
LaTeX Homework Template
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{homework}
\usepackage[margin=1in]{geometry}
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage[many]{tcolorbox}
\usepackage{mathtools,amsthm,amssymb,amsfonts,bm}
\usepackage{thmtools,amsmath}
\usepackage{marginnote,sidenotes}
\usepackage{fancyhdr}
\usepackage{titlesec}
\usepackage{setspace}
\usepackage{enumitem}
\usepackage{graphicx, svg}
\usepackage[bookmarks=true]{hyperref}
\usepackage{bookmark}
%% Constants %%
% Making epsilons look like epsilons...
\renewcommand{\epsilon}{\varepsilon}
\newcommand{\eps}{\epsilon}
\newcommand{\A}{\forall}
\newcommand{\E}{\exists}
\newcommand{\N}{\mathbb{N}}
\newcommand{\Q}{\mathbb{Q}}
\newcommand{\R}{\mathbb{R}}
\newcommand{\Z}{\mathbb{Z}}
%% Frequently-used snippets %%
\newcommand{\abs}[1]{\left| #1 \right|}
\newcommand{\absle}[1]{\abs{#1} < \eps}
\newcommand{\absld}[1]{\abs{#1} < \delta}
\newcommand{\integral}[2]{\int_{#1}^{#2}}
\newcommand{\intab}{\integral{a}{b}}
\newcommand{\func}[2][f]{#1 \colon #2 \to \R}
\newcommand{\fabr}{\func[f]{[a,b]}}
\newcommand{\fog}{f \circ g}
\newcommand{\gof}{g \circ f}
\newcommand{\set}[1]{\left\{ #1 \right\}}
\newcommand{\partition}[1][P]{#1 = \set{x_0,x_1,\ldots,x_n}}
\newcommand{\deltaxi}{\Delta x_{i}}
\newcommand{\deltaxk}{\Delta x_{k}}
\newcommand{\lowersum}[1][f]{L(#1,P) = \sum^n_{i=1} m_i\deltaxi}
\newcommand{\uppersum}[1][f]{U(#1,P) = \sum^n_{i=1} M_i\deltaxi}
%% Convenience Wrappers %%
\newcommand{\hint}[1]{
\begin{tcolorbox}[title=Hint]
#1
\end{tcolorbox}
}
%% Document Setup %%
\makeatletter
\let\Title\@title
\let\Author\@author
\let\Date\@date
\makeatother
%% \usepackage{graphicx, svg} %%
\graphicspath{{images/}}
\svgpath{{images/}}
%% \usepackage{fancyhdr} %%
\pagestyle{fancy}
\setlength{\headheight}{25pt}
\lhead{\Title}
\rhead{\Author}
%% \usepackage{hyperref} %%
\hypersetup{
pdfauthor={\Author},
pdftitle={\Title},
linktoc={all}
}
%% \usepackage{titlesec} %%
\titleformat{\subsection} % command
[runin] % shape
{\normalfont\bfseries} % format
{\thesubsection} % label
{1em} % sep
{}
\titleformat{\subsubsection} % command
[runin] % shape
{\normalfont\bfseries} % format
{\thesubsubsection} % label
{1em} % sep
{}
%% Spacing/Formatting %%
\setstretch{1.3}
\newcommand{\resetpar}{
\setlength{\parskip}{0.5em}
}
%% tcolorbox Environments %%
\renewenvironment{proof}
{{\sffamily\bfseries Proof. }\resetpar}
{\qed}
\tcbset{
boxrule=0pt,
sharp corners,
enhanced jigsaw,
drop fuzzy shadow,
breakable
}
\newtcolorbox{answer}{
beforeafter skip balanced=25pt,
colback={White!90!CornflowerBlue},
borderline west={3pt}{0pt}{NavyBlue!80!white}
}
\tcolorboxenvironment{proof}{
beforeafter skip balanced=25pt,
colback={White!90!CornflowerBlue},
borderline west={3pt}{0pt}{NavyBlue!80!white}
}
%% Show code and output %%
%% (From: https://tex.stackexchange.com/questions/194854/how-to-show-latex-commands-in-text-mode/392818) %%
\newcommand{\gfcb}[1]{%
\fcolorbox{white}{gray!10!}{\quad\strut #1\quad}
} % gfcb := gray fcolorbox
\newcommand{\cop}[1]{%
\gfcb{\texttt{\detokenize{#1}}}
\ensuremath{\quad \longrightarrow \quad & #1}
} % cop := code output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment