\documentclass[a4paper,12pt]{article}
\usepackage{amsmath,amsfonts,graphicx}
\usepackage{float}
\usepackage{hyperref}
\usepackage{subcaption}

\bibliographystyle{ieeetr}

\begin{document}
\tableofcontents
\listoffigures
\listoftables
\newpage

\section{Heading 1}\label{sec:head1}
This is a section.
\subsection{Sub Heading 1}
And here we have reached a subsection under section \ref{sec:head1}.
\subsection*{Sub Heading 2}
This is an unnumbered section. This sentence shows the different formatting options: \textbf{bold}, \textit{italic}, \emph{emphasize}. You can also make text \huge{huge} or \small{small} or any combination like \textbf{\huge{bold and large}}.

\section{Heading 2}
This section contains examples of the most used environments.

\subsection{Maths}

There are two ways of included mathematical expression, in-line . Maths expressions enclosed in \$ is used to create in-line maths. E.g. $c^2=a^2+b^2$.\\

Maths that does not need to be in-line can be typeset using the \textit{equation} environment. For example:
\begin{equation}
\frac{d f}{dx}=\lim_{\Delta x \rightarrow 0}\frac{f(x+\Delta x)-f(x)}{\Delta x},
\label{eqn:eq1}
\end{equation}
if we wanted to add multiple equations that are aligned we use the \textit{align} environment as follows:
\begin{align}
\frac{d}{dx}(x+y)^{2}&=\frac{d}{dx}\left[ x^{2}+y^{2}+2xy\right], \nonumber\\
&=2x+2y. \label{eqn:eq2}
\end{align}
as in other environments we can use the \textit{label} command to refer to equations. As you can see in equations \ref{eqn:eq1} and \eqref{eqn:eq2} typing maths in \LaTeX{} is fun and easy.

\subsection{Advanced maths}
Latex can be used to generate various Greek letters, such as:
\begin{alignat*}{4}
  &\alpha \quad& \beta \quad & \gamma \quad & \Gamma \\  
  &\zeta \quad &\psi  \quad & \chi \quad & \nu \\
  &\tau \quad & \varphi \quad & \varepsilon \quad & \lambda.
\end{alignat*}
There are also a number of integrals that can be defined in Latex:
\begin{equation}
  \hat{F}(\omega)=\int_{0}^{2 \pi}f(x)e^{2\pi i \omega x}dx.
  \label{eqn:eq3}
\end{equation}
\begin{equation}
  A=\iint_{S} f(x,y) dS.
  \label{eqn:eq4}
\end{equation}
\begin{equation}
  V=\iiint_{V} f(\mathbf{x},\mathbf{y},\mathbf{z}) dV.
  \label{eqn:eq5}
\end{equation}
\begin{equation}
  \oint_{\gamma} f(z)dz=2\pi i\sum_{k=1}^{n} Res(f,a_{k}).
  \label{eqn:eq6}
\end{equation}
A number of differential operators are also available:
\begin{equation}
  \left[ \nabla^{2}+k^{2} \right]p(x,y,t)=0.
  \label{eqn:eq7}
\end{equation}
One can also use Latex to typeset matrices such as:
\begin{equation}
  \begin{bmatrix}
    a11 & a12 & a13\\
    a21 & a22 & a23\\
    a31 & a32 & a33\\
  \end{bmatrix}
  \begin{pmatrix}
    x \\
    y \\
    z 
  \end{pmatrix}
  =
  \begin{pmatrix}
    f1 \\
    f2 \\
    f3
  \end{pmatrix}
  \label{eqn:eq8}
\end{equation}
And some more advanced stuff \footnote{Hint: Look up the array and mathbb functions.}:
\begin{equation} 
  \sqrt{x} =
\left\{
	\begin{array}{ll}
	  \mathbb{R} & \mbox{if } x \geq 0 \\
	  \mathbb{I} & \mbox{if } x < 0
	\end{array}
\right.
  \label{eqn:multipart}
\end{equation}

\newpage
\subsection{Figures}
In \LaTeX{} it also possible to create two figures next to each other, these are called sub figures.

\begin{figure}[htb]
    \centering
    \begin{subfigure}[b]{0.475\textwidth}
        \centering
        \includegraphics[width=\textwidth]{phd-front.jpg}
        \caption{Caption on first figure}
        \label{fig:subfig1}
    \end{subfigure}
    \hfill
    \begin{subfigure}[b]{0.475\textwidth}
        \centering
        \includegraphics[width=\textwidth]{phd-front.jpg}
        \caption{Caption on second figure}
        \label{fig:subfig2}
    \end{subfigure}
    \caption{These are funny pictures}
    \label{fig:funnypic}
\end{figure}

References can be to the figure \ref{fig:funnypic} or to the sub-figures \ref{fig:subfig1} or \ref{fig:subfig2}.

\subsection{Lists}
\LaTeX{} also allows various ways to list text. They can either be numbered lists or unnumbered lists. An example of these are:
\begin{enumerate}
	\item We have so far learnt how to structure a document.
	\item How to format text.
	\item How to use various math environments.
	\item How to display graphics.
\end{enumerate}

or in unnumbered fashion and multiple levels:

\begin{itemize}
	\item We have so far learnt how to structure a document.
		\begin{itemize}
			\item in sections
			\item in subsections
			\item in subsubsections
		\end{itemize}
	\item How to format text.
		\begin{itemize}
			\item in \textbf{bold}
			\item in \textit{italic}
			\item in \emph{emphasize}
		\end{itemize}
	\item How to use various math environments.
	\item How to display graphics.
\end{itemize}

%Useful command
\subsection{Tables}
\LaTeX{} allows you you to include your hard earned data in tables such as:

\begin{table}[htb]
\caption{A table with useless info.}
\label{tab:tab1}
\centering
	\begin{tabular}{c|l|l}
	S.No. & Price [\$] & Stock \\ 	
	\hline
	\hline
	1 & 200 & 5 \\
	2 & 65 & 7 \\
	3 & 198 & 8 \\
	\end{tabular}
\end{table}

For more \LaTeX{} info see\cite{goossens93} and \cite{greenwade93}.

%% bibliography
\bibliography{library}

\end{document}
