Latex Cheatsheet

% include a figure:

\begin{figure}[hbtp]

\caption{Your Figure Here}\label{myfig}

\includegraphics[scale=.7]{YourFigure.png}

\end{figure}


% include a table:

\begin{table}[htbp]

\begin{center}

\renewcommand\thetable{5} % personalize the table number

\caption{This table is a copy and paste from wikibook}\label{T1}

\begin{tabular}{llr}

\hline

\multicolumn{2}{c}{Item} \\

\cline{1-2}

%\cmidrule(r){4-5} \cmidrule(r){6-7} % give gap between two \cline.

Animal & Description & Price (\$) \\

\hline

Gnat & per gram & 13.65 \\

& each & 0.01 \\

Gnu & stuffed & 92.50 \\

Emu & stuffed & 33.33 \\

Armadillo & frozen & 8.99 \\

\hline

\end{tabular}

\end{center}

\end{table}


%Table with shaded column: Add this two to preamble

\usepackage{xcolor,colortbl}


\newcommand{\mc}[2]{\multicolumn{#1}{c}{#2}}

\definecolor{Gray}{gray}{0.85}

\definecolor{LightCyan}{rgb}{0.88,1,1}


\newcolumntype{a}{>{\columncolor{Gray}}c}

\newcolumntype{b}{>{\columncolor{white}}c}


%Reshape the table to fit in the page:Add this to preamle

%Aand add float text under a table or graph

\usepackage{graphicx} %Reshape the table

\usepackage{floatrow} %Float text

\begin{table}[htbp]

\centering

\caption{Agriculture Employment Share}

\resizebox{\linewidth}{!}{ %Reshape the table to fit in the page

\begin{tabular}{r| a b a b a b a b a b} %Table with shaded column

\hline

\rowcolor{white}

\multicolumn{3}{l}{\textbf{PanelA: Census}} & \multicolumn{8}{c}{Regions} \\ % multi column

\cline{4-11}\\ % line for specific column

\rowcolor{white}

Year & National & & East & & Central & & West & & Northeast & \\

\hline

1985 & 71.81\% & 100\% & 18.02\% & 25\% & 27.12\% & 38\% & 22.57\% & 31\% & 4.10\% & 6\% \\

\hline

\end{tabular}%

}

\floatfoot{ * Shaded columns are normalized regional contribution.} % float text under a table or graph

\end{table}%


% Add footnote under a table: put under \end{tabular}

\raggedright{\footnotesize{*This is a footnote under a table}}


% Add notes below the table: three part table

\usepackage[para,online,flushleft]{threeparttable}

\begin{table}[h]

\caption{Some very informative caption}

\begin{center}

\begin{threeparttable}

\begin{tabular}{c c}

\toprule

content1 & content2

\end{tabular}

\begin{tablenotes}

\item[1] note1; \item[2] note2

\end{tablenotes}

\end{threeparttable}

\end{center} \label{tablelabel}

\end{table}


% Float note under graph or table

\usepackage[capposition=top]{floatrow}

\floatfoot{*Note the y scales are different.}


% Bibliography - Natbib