LaTeX

The below is the preamble I use for most of my lay-tech documents, which I always write in TeXstudio.

\documentclass[12pt, letterpaper]{article}
\usepackage[left=2.5cm,right=2.5cm, top=2.5cm, bottom=2.5cm]{geometry}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead[R]{Flaherty, \thepage}



%1. General Packages%
\renewcommand{\headrulewidth}{2pt}
\setlength{\headheight}{15pt}
\usepackage{lipsum}
\usepackage{amsmath}
\usepackage[makeroom]{cancel}
\usepackage{cancel}
\usepackage{array,polynom}
\newcolumntype{C}{>{{}}c<{{}}} 
\newcolumntype{R}{>{\displaystyle}r}  
\usepackage{xcolor}
\newcommand\Ccancel[2][black]{\renewcommand\CancelColor{\color{#1}}\cancel{#2}}
\usepackage{amssymb}
\usepackage{bbm}
\usepackage{mathrsfs}
\usepackage[toc]{glossaries}
\usepackage{amsthm}
\usepackage{indentfirst}
\usepackage[utf8]{inputenc}
\usepackage[thinc]{esdiff}
\usepackage{graphicx}
\graphicspath{{./images/}}
\usepackage{subfig}
\usepackage{chngcntr}
\usepackage{placeins}
\usepackage{caption}
\usepackage{float}
\usepackage{comment}
\usepackage{sectsty}
\sectionfont{\fontsize{15}{15}\selectfont}
\usepackage{subcaption}
\setlength\abovedisplayskip{0pt}
\usepackage[hidelinks]{hyperref}
\usepackage[nottoc,numbib]{tocbibind}
\renewcommand{\qedsymbol}{\rule{0.7em}{0.7em}}
\newcommand{\Mod}[1]{\ (\mathrm{mod}\ #1)}
\counterwithin{figure}{section}
\usepackage{centernot}
\usepackage{enumitem}  



%2. Numbering and Math Types%             
\theoremstyle{definition}
\newtheorem{definition}{Definition}[section]
\newtheorem{prop}{Proposition}[section]
\newtheorem{theorem}{Theorem}[section]
\newtheorem{lemma}{Lemma}[theorem]
\newtheorem{corollary}{Corollary}[theorem]
\numberwithin{equation}{section}

\newcounter{problem}[section]
\renewcommand{\theproblem}{\thesection.\arabic{problem}}
\newcommand{\problem}{
	\refstepcounter{problem}
	\noindent \textbf{Problem \theproblem)}
}

\newcounter{ex}[section] 
\renewcommand{\theex}{\thesection.\arabic{ex}} 
\newenvironment{ex}{
	\par\smallskip 
	\refstepcounter{ex}
	\noindent\textit{Example \theex:}
	\leftskip=0.5em
}{
	\par\smallskip
	\leftskip=0em
}

\newcounter{nonex}[section] 
\renewcommand{\thenonex}{\thesection.\arabic{nonex}} 
\newenvironment{nonex}{
	\par\smallskip 
	\refstepcounter{nonex}
	\noindent\textit{Non-example \thenonex:}
	\leftskip=0.5em
}{
	\par\smallskip
	\leftskip=0em
}



%3. Easy References%
\newcommand{\mydef}[1]{(Definition \ref{#1}, Page \pageref{#1})}
\newcommand{\myprop}[1]{(Proposition \ref{#1}, Page \pageref{#1})}
\newcommand{\mylemma}[1]{(Lemma \ref{#1}, Page \pageref{#1})}
\newcommand{\mytheorem}[1]{(Theorem \ref{#1}, Page \pageref{#1})}
\newcommand{\mycor}[1]{(Corollary \ref{#1}, Page \pageref{#1})}
\newcommand{\myeq}[1]{(Equation \ref{#1}, Page \pageref{#1})}
\newcommand{\myprob}[1]{(Problem \ref{#1}, Page \pageref{#1})}
\newcommand{\myex}[1]{(Example \ref{#1}, Page \pageref{#1})}
\newcommand{\mynonex}[1]{(Non-example \ref{#1}, Page \pageref{#1})}
\newcommand{\clickableword}[2]{\hyperref[#1]{#2}}



%4. Commutative Diagrams%
\usepackage{tikz}                     
\usetikzlibrary{arrows}               
\usetikzlibrary{shapes.geometric}  
\usetikzlibrary{calc}
\pgfkeys{/tikz/.cd,
num vertex/.initial=4,
num vertex/.get=\vertices,
num vertex/.store in=\vertices,
circle radius/.initial=3,
circle radius/.get=\circleradius,
circle radius/.store in=\circleradius,
shift angle/.initial=0,
shift angle/.get=\shiftangle,
shift angle/.store in=\shiftangle, 
at pos/.initial={(0,0)},
at pos/.get=\position,
at pos/.store in=\position,
vertex radius/.initial=1.5pt,
vertex radius/.get=\vertexradius,
vertex radius/.store in=\vertexradius,
}
\makeatletter
\def\drawvertices{\tikz@path@overlay{node}}
\makeatother   
\pgfkeys{/tikz/circumference with labels/.code={
\pgfmathsetmacro\halfcircleradius{\circleradius/2}
\draw \position circle (\halfcircleradius cm) node[regular polygon, regular polygon sides=\vertices, minimum size=\circleradius cm, draw=none, name={vertex set}] {};
\foreach \textlabel/\circlecolor [count=\x] in {#1}{
	\node[draw,circle, inner sep=\vertexradius,black, fill=\circlecolor] at (vertex set.corner \x) {};
	\pgfmathparse{\shiftangle-360*(\x-1)/ \vertices}
	\node at ($(vertex set)+(\pgfmathresult:\halfcircleradius)$)[label={[font=\small]\pgfmathresult:$\textlabel$}]{};
}
}
}



%5. Custom command for matrices%
\newcommand{\mymatrix}[1]{
\renewcommand{\arraystretch}{0.5} 
\setlength\arraycolsep{3pt}       
\scalebox{0.90}{                  
$\begin{bmatrix}
	#1
\end{bmatrix}$
}                   
\renewcommand{\arraystretch}{1.0} 
\setlength\arraycolsep{6pt}       
}



%6. Underscript for algebraic operations%
\newcommand{\+}[1]{+_{\scalebox{.575}{$\scriptstyle #1$}}}
\newcommand{\mult}[1]{\cdot_{\scalebox{.575}{$\scriptstyle #1$}}}



%7. Shortcuts for estimators%
\newcommand{\estimator}[1]{\underset{\sim}{#1}}
\newcommand{\mom}[1]{\underset{\sim}{#1_{\scalebox{0.35}{MOM}}}}
\newcommand{\mle}[1]{\underset{\sim}{#1_{\scalebox{0.35}{MLE}}}}



%8. Limits for summands and such%
\newcommand{\mysum}[2]{\sum\limits_{#1}^{#2}}
\newcommand{\myprod}[2]{\prod\limits_{#1}^{#2}}
\newcommand{\mylim}[2]{\lim\limits_{#1}{#2}}



%9. Derivatives and integrals%
\newcommand{\drv}[2]{\frac{d #1}{d #2}}
\newcommand{\pdrv}[2]{\frac{\partial #1}{\partial #2}}
\newcommand{\myint}[4]{\int\limits_{#3}^{#4} #1 \; d #2}



%10. Blackboard for letters%
\newcommand{\R}{\mathbb{R}}
\newcommand{\N}{\mathbb{N}}
\newcommand{\C}{\mathbb{C}}
\newcommand{\Z}{\mathbb{Z}}
\newcommand{\F}{\mathbb{F}}
\newcommand{\Q}{\mathbb{Q}}
\newcommand{\K}{\mathbb{K}}
\newcommand{\E}{\mathbb{E}}
\newcommand{\V}{\mathbb{V}}
\newcommand{\1}{\mathbbm{1}}
\newcommand{\Prob}{\mathbbm{P}}
\newcommand{\Probr}{\widetilde{\mathbb{P}}}
\newcommand{\Er}{\widetilde{\mathbb{E}}}
\newcommand{\Fc}{\mathcal{F}}



%My title page%
\title{A Fake Title For Illustration}
\author{Liam Flaherty}
\date{\parbox{\linewidth}{\centering
Professor Name\endgraf\bigskip
Class Code \endgraf\bigskip
Month DD, YYYY \endgraf}}


\begin{document}
\maketitle
\thispagestyle{empty}
\newpage\tableofcontents

\newpage\clearpage\noindent
\section{Labels And References}\label{section.labels}
\subsection{Showing Shortcuts}\label{subsection.shortcuts}

\begin{definition}\label{def.firstdefinition}
	\textbf{Label and Reference:} LaTeX makes references easy.
\end{definition}

If I want to refer to the above definition, I can use the technique in section 3 of my preamble and do something like \mydef{def.firstdefinition} instead of manually typing out the format I want each time. The same type of idea is used to make referencing theorems, corollaries, examples, etc. easier.



\newpage
\subsection{Math Specific Shortcuts}
\label{subsection.mathspecific}

While LaTeX's glossary is generally pretty good, you can get more control by doing something like the below as a way to force a level to appear.
\addcontentsline{toc}{subsubsection}{\numberline{}A way to Insert a line in toc }
\vspace{\baselineskip}

But enough of the overview, below are some of the math shortcuts from my preamble in action:
\vspace{\baselineskip}

\begin{enumerate}
	\itemsep0em %no space between items!%
	\item Matrices can be done with: $\mymatrix{3 & 0 & 0 & 6\\
		9 & 18 & -24 & 0\\
		9 & 0 & 9 & -15} 
	\overrightarrow{
		\substack{
			r_2'=r_2-3r_1\\
			r_3'=r_3-r_1}}
	\mymatrix{3 & 0 & 0 & 6\\
		0 & 18 & -24 & 0\\
		0 & 0 & 9 & -15}$
	\item To reference estimators, I like $\estimator{\theta}$. We can get more specific with $\mom{\theta}$. 
	\item Estimates I just use the classic $\widehat{\theta}$
	\item References to algebraic operations can be made precise with, e.g. $\mult{\K}$ or $\+{G}$
	\item I always prefer the limit that looks like $\mylim{x \to \infty}{f(x)}$
	\item Likewise I almost always prefer a definite integral that looks like $\myint{f(x)}{x}{a}{b}$
\end{enumerate}



\newpage
\section{Appendix}
\label{section.appendix}

The below is a way to insert longer chunks of code. If I want to write something short in-line, I will do something like: \texttt{This is a font for code}.


{\scriptsize
	\begin{verbatim}
		#####2. Confidence Intervals#####
		#Want to investigate for CLT that P(E(X) is within \pm 1.96 sd/\sqrt{n} of sample mean) \approx 0.95#
		###2a. The initial parameters###
		n=1000                                   #sample size#
		N=10000                                  #number of times to reproduce#
		set.seed(548)                            #for reproducibility#
\end{verbatim}}

\end{document}