LaTeX
Related pages: Beamer • Table formatting • Data visualization • Diagramming
Templates¶
% PDFLATEX
\documentclass[12pt, oneside]{article}
% FAST COMPILATION
% \pdfcompresslevel=0
% \pdfobjcompresslevel=0
% LAYOUT
\usepackage{geometry}
\geometry{
margin=1in,
a4paper
}
% PAGESTYLE
% \usepackage{fancyhdr, lastpage}
% \pagestyle{fancy}
% \fancyhf{}
% \lhead{\small\sffamily <title>}
% \rhead{\small
% \sffamily
% Page \thepage\ of \pageref*{LastPage}
%}
% FONT
%\usepackage{fourier}
%\usepackage{mathptmx}
\usepackage{lmodern}
% COLOR
\usepackage{xcolor}
\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}
% HYPERREF
\usepackage[bookmarksnumbered, hidelinks]{hyperref}
\usepackage{url}
% TOC_COLOR
% \usepackage{xcolor}
% \colorlet{RED}{black} % don't color running headers
% \colorlet{BLUE}{black}
% \usepackage[titles]{tocloft}
% \renewcommand{\cftchapfont}{\bfseries\color{blue}}
% \renewcommand{\cftchappagefont}{\bfseries\color{blue}}
% TITLE_LINK
\usepackage[explicit]{titlesec}
% https://tex.stackexchange.com/questions/32495/linking-the-section-text-to-the-toc#:~:text=It%20links%20back%20to%20the%20toc%20by%20setting,can%20easily%20copy%20this%20approach%20for%20chapters%20etc.
% chapter
% \titleformat{\chapter}[display]
% {\normalfont\huge\bfseries}{\chaptertitlename\ {\fontfamily{cmr}\selectfont\thechapter}}{20pt}{\hyperlink{chap-\thechapter}{\Huge#1}\addtocontents{toc}{\protect\hypertarget{chap-\thechapter}{}}}
% chapter*
% \titleformat{name=\chapter,numberless}
% {\normalfont\huge\bfseries}{}{-20pt}{\Huge#1}
% section
\titleformat{\section}
{\normalfont\Large\bfseries}{\thesection}{1em}{\hyperlink{sec-\thesection}{#1}\addtocontents{toc}{\protect\hypertarget{sec-\thesection}{}}}
% section*
\titleformat{name=\section,numberless}
{\normalfont\Large\bfseries}{}{0pt}{#1}
% subsection
\titleformat{\subsection}
{\normalfont\large\bfseries}{\thesubsection}{1em}{
\hyperlink{subsec-\thesubsection}{#1}\addtocontents{toc}{\protect\hypertarget{subsec-\thesubsection}{}}
}
% subsection*
% \titleformat{name=\subsection,numberless}
% {\normalfont\large\bfseries}{\faCube\phantom{ }
% % \thesubsection
% }{0pt}{#1}
% LISTS
\usepackage{enumitem}
% \setlist{nosep}
% GRAPHS
\usepackage{graphicx}
% \graphicspath{{graphs/}}
% PDF pages
\usepackage{pdfpages}
\usepackage{subcaption}
% TABLES
\usepackage{booktabs}
\usepackage[flushleft]{threeparttable}
\usepackage{adjustbox}
\usepackage[font={sc}]{caption}
\makeatletter\let\expandableinput\@@input\makeatother
% use \expandableinput filename.tex instead of \input{filename.tex}
\usepackage{siunitx}
\sisetup{
input-symbols = {()}, % do not treat "()" in any special way
output-decimal-marker={.},
parse-numbers = true,
group-digits = all,
group-separator = {,}
}
\usepackage{makecell}
\usepackage{longtable}
% MATH
\usepackage{amsmath}
\DeclareMathOperator{\e}{E}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{cleveref}
% plain (italic)
\theoremstyle{plain}
\newtheorem{theorem}{Theorem}[section]
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{definition}[theorem]{Definition}
\newtheorem{assumption}[theorem]{Assumption}
% definition
\theoremstyle{definition}
\newtheorem{claim}[theorem]{Claim}
\newtheorem{algorithm}[theorem]{Algorithm}
\newtheorem{problem}[theorem]{Problem}
% remark: no extra space
\theoremstyle{remark}
\newtheorem{remark}[theorem]{Remark}
\newtheorem*{example}{Example}
\newtheorem*{solution}{Solution}
\newtheorem*{note}{Note}
% other math packages
\usepackage{bm}
\usepackage{mathtools}
\usepackage{IEEEtrantools}
% BIBLIOGRAPHY
\usepackage{natbib}
% LISTINGS
\usepackage{listings}
\lstdefinestyle{mystyle}{
backgroundcolor=\color{backcolour},
commentstyle=\color{codegreen},
keywordstyle=\color{magenta},
numberstyle=\tiny\color{codegray},
stringstyle=\color{codepurple},
basicstyle=\ttfamily\footnotesize,
breakatwhitespace=false,
breaklines=true,
captionpos=b,
keepspaces=true,
numbers=left,
numbersep=5pt,
showspaces=false,
showstringspaces=false,
showtabs=false,
tabsize=2
}
\lstset{style=mystyle}
% SYMBOLS
\usepackage{fontawesome}
% TOOLS
\usepackage{lipsum}
% BASIC INFO
\title{}
\author{}
\date{}
% DOCUMENT
\begin{document}
\begin{sloppypar}
% TITLE
\maketitle
% TOC
% \tableofcontents
% BIB
% \bibliographystyle{econ-aea}
% \bibliography{"PATH_TO_BIB_FILE"}
\end{sloppypar}
\end{document}
Introduction to LaTeX¶
Resources¶
LaTeX editors¶
Tex engines¶
Document setup¶
Compilation¶
TBD
Page layout¶
TBD
Fonts¶
TBD
Colors¶
Navigation¶
TBD
Header and footer¶
TBD
Title formating¶
titlesec
Elements¶
Scalars¶
Tables¶
Table with notes (`minipage`)
\begin{table}[htbp]
\centering
% \caption{}
% \label{tab:}
\footnotesize
% \input{}
\begin{minipage}{0.8\textwidth}
\vspace{1ex}
\footnotesize
\textit{Notes}: This table presents ...
\end{minipage}
\end{table}
Table with notes (`threeparttable`)
\begin{table}[htbp]
\centering
% \caption{}
% \label{tab:}
\begin{threeparttable}
\footnotesize
% \input{}
\begin{tablenotes}[flushleft]
\footnotesize
\item\hspace*{-0.3em}\textit{Note:} Standard errors in parentheses.
% \item\hspace*{-0.3em}\textit{Source:}
\end{tablenotes}
\end{threeparttable}
\end{table}
Figures¶
Figure
\begin{figure}[htbp]
\centering
% \includegraphics[width=0.8\textwidth]{}
% \caption{}
% \label{fig:}
\end{figure}
Figure with notes
\begin{figure}[htbp]
\centering
% \includegraphics[width=0.8\textwidth]{}
% \caption{}
% \label{fig:}
\begin{minipage}{0.8\textwidth}
\vspace{1ex}
\footnotesize
\textit{Notes:} This figure shows ...
\end{minipage}
\end{figure}
Math¶
Math symbols
Citations and bibliography¶
For more information about managing references, see Reference managers.
To download the AEA bibliography style file (aea.bst), click "LaTeX" from the link below:
Lists¶
TBD
Code blocks¶
TBD
Compilation¶
latexmk: