%% Copyright 2016 - Silke Hofstra & Matthijs van Minnen
%
% Licensed under the EUPL, Version 1.1 or -- as soon they will be approved by
% the European Commission -- subsequent versions of the EUPL (the "Licence");
% You may not use this work except in compliance with the Licence.
% You may obtain a copy of the Licence at:
%
% https://joinup.ec.europa.eu/software/page/eupl
%
% Unless required by applicable law or agreed to in writing, software
% distributed under the Licence is distributed on an "AS IS" basis,
% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
% express or implied.
% See the Licence for the specific language governing
% permissions and limitations under the Licence.

% !TEX spellcheck = en_GB
\documentclass[xcolor={usenames,dvipsnames,table,svgnames},aspectratio=169, 12pt]{beamer}
\usepackage[T1]{fontenc}
\usepackage{amsmath,hyperref,listings,graphicx,caption,parskip,metalogo,soul,textgreek}
\usepackage[english]{babel}

\graphicspath{{./figures/}}

\usecolortheme{beaver}
\definecolor{Scintilla-red}{RGB}{228,0,43}
\definecolor{darkred}{RGB}{205,0,0}

\usefonttheme[onlymath]{serif}
\setbeamercolor{itemize item}{fg=darkred,bg=darkred}
\setbeamercolor{block title}{fg=darkred}
\setbeamercolor{structure}{fg=darkred}
\setbeamercolor{section name}{fg=darkred}
\setbeamercolor{section title}{fg=darkred}
\setbeamertemplate{navigation symbols}{}
\setbeamertemplate{caption}{caption name own line}
\setbeamertemplate{section in toc}[circle]
\setbeamertemplate{section page}{
  \vfill
  \begin{beamercolorbox}[center,sep=8pt,shadow=false,rounded=false]{title}
     \Huge\usebeamercolor{section title}\secname
  \end{beamercolorbox}
  \centering
  \large Section \insertsectionnumber
  \vfill
  \includegraphics[width=.2\textwidth]{masterclass}
}

\hypersetup{colorlinks=true,linkcolor=black,urlcolor=darkred}

\setlogokern{eL}{-0.06em}

\setkeys{Gin}{keepaspectratio}
\captionsetup{labelformat=empty,labelsep=none}

\title{An introduction to \LaTeX}
\subtitle{Scintilla's \LaTeX\ course}
\titlegraphic{\vspace{-.5cm}\flushleft\includegraphics[width=.2\textwidth]{masterclass}}
\author{Scintilla's MasterCLASS}


%\AtBeginSection[]
%{
  %\begin{frame}{Table of Contents}
    %\tableofcontents[currentsection]
  %\end{frame}
%}

% Listings config
\lstset{
	language=[LaTeX]TeX,
	morekeywords={\command,\url,\href,\hypersetup,\chapter,\subsection,\subsubsection,\part,\paragraph,\subparagraph,\begin,\end,\lstinputlisting},
	upquote=true,
	numbers=none,
	numberstyle=\tiny\color{Gray}\ttfamily,
	stepnumber=1,
	numbersep=5pt,
	rulecolor=\color{black},
	backgroundcolor=\color{black!10},
	tabsize=4,
	captionpos=r,
	breaklines=true,
	breakatwhitespace=true,
	breakindent=0pt,
	title=\lstname,
	keywordstyle=\color{RoyalBlue},
	commentstyle=\color{ForestGreen},
	stringstyle=\color{WildStrawberry},
	xleftmargin=0mm,
	xrightmargin=0mm,
	%aboveskip=2mm,
	%belowskip=0mm
}
\lstMakeShortInline[columns=fixed, basicstyle = \ttfamily]|

\lstdefinelanguage{BibTeX}
  {keywords=[1]{%
      @article,@book,@collectedbook,@conference,@electronic,@ieeetranbstctl,%
      @inbook,@incollectedbook,@incollection,@injournal,@inproceedings,%
      @manual,@mastersthesis,@misc,@patent,@periodical,@phdthesis,@preamble,%
      @proceedings,@standard,@string,@techreport,@unpublished,%
      },
	 keywords=[2]{address,annote,author,booktitle,chapter,crossref,edition,editor,
			howpublished,institution,journal,key,month,note,number,organization,pages,
			publisher,school,series,title,type,volume,year
			},
   comment=[l][\itshape]{@comment},
   sensitive=false,
  }
  

\begin{document}

\frame{\titlepage}

\section{Why use \LaTeX{}?}

\begin{frame}{'Ease' of use}
	"Latex makes difficult things easy, and easy things very difficult" \\
	\hfill --- \href{http://umij.wordpress.com/2013/03/08/latex-vs-word-2010-and-why-you-should-not-use-latex-for-smaller-documents/}{Umij}
	\vfill
	\begin{figure}
		\includegraphics[height=.6\textheight]{miktex}
		\caption{\tiny Source: \href{http://www.pinteric.com/miktex.html}{Marko Pinteric}}
	\end{figure}
\end{frame}

\begin{frame}[fragile]{But what \emph{is} \LaTeX?}
	\LaTeX\ is a language that allows you to create documents in almost any text editor by
	focusing primarily on \emph{content} and \emph{structure}, not \emph{how it looks}.
	
	\hfill
	
	\begin{columns}[c]
		\column{.45\textwidth}
		  \includegraphics[width=\columnwidth]{editor-word}
	  \column{.4\textwidth}
		  \includegraphics[width=\columnwidth]{editor-latex}
		\end{columns}
\end{frame}


\begin{frame}[fragile]{There is a difference between content and looks!}
	\begin{block}{Example:}
	To emphasise something in Word, one makes it \textit{italic}. \\
	In \LaTeX\ one places \emph{emphasis}.
	\bigskip
	
	One can change how \emph{emphasis} behaves but not how \textit{italic} behaves.
	\end{block}
	
	\vfill
	
	\begin{block}{Example:}
	  What is the difference between the following lines?	
	  \begin{columns}[onlytextwidth]
	  \begin{column}{.4\linewidth}
		  \textbf{\Large New Chapter}\\
	    \textbf{\Large New Chapter}
    \end{column}
    \pause  
	  \begin{column}{.6\linewidth}
      \begin{lstlisting}
 \section*{New Chapter}
 \textbf{\Large{New Chapter}}
      \end{lstlisting}
    \end{column}
	  \end{columns}
	\end{block}
\end{frame}

\section{Difference with ordinary text editors}
\begin{frame}[fragile]{\LaTeX\ vs MS Office}
	\begin{columns}[t,onlytextwidth]
		\begin{column}{.5\textwidth}
		Avantages of MS Office include:
		\begin{itemize}
			\item Showing you what you get \emph{immediately}
			\item Checking spelling/grammar
			\item Easy to use
			\item Everything is in one 'package'
		\end{itemize}
	\end{column}
	
	\begin{column}{.5\textwidth}
		Advantages of \LaTeX\ include:
		\begin{itemize}
			\item Separating \emph{content} and \emph{formatting}
			\item Mathematical equations
			\item Placing and refering to images
			\item Automation, programmability and consistency
			\item High quality typography (kerning, hyphenation, etc)
			\item Keeping money in your pockets
			% Referencing
		\end{itemize}
		\end{column}
	\end{columns}
\end{frame}



\section{Table of Contents}
\begin{frame}{Table of Contents}
    \begin{columns}[onlytextwidth,T]
        \begin{column}{.55\textwidth}
            \tableofcontents[sections=1-4]
        \end{column}
        \begin{column}{.45\textwidth}
            \tableofcontents[sections=5-10]
        \end{column}
    \end{columns}
\end{frame}






% \section{How to get started with \LaTeX}
% \begin{frame}{The editor}
%   \begin{figure}
%     \includegraphics[width=\textwidth]{texworks}    
%   \end{figure}
% \end{frame}


% \begin{frame}[fragile]{Using \LaTeX\ - A basic example}
% 	\begin{lstlisting}[basicstyle = \ttfamily\small]
% \documentclass{article}
% \usepackage{graphicx}
%
% \begin{document}
%   \section{Welcome}
%   Welcome to \LaTeX\, enjoy this simple document!
% \end{document}
% 	\end{lstlisting}
% \end{frame}



\section{Syntax}
\frame{\sectionpage}

\subsection{Commands}
\begin{frame}[fragile]{Commands}
  A command starts with $\backslash$ followed by a keyword, e.g. \lstinline[columns=fixed, basicstyle = \ttfamily]|\documentclass[]{}|. Where \{ \} define a place for required arguments and [ ] for optional arguments.\\
  \bigskip
  Required argument: article, IEEEtran, report, book, \emph{beamer} and more!\\
  Optional argument: 11pt, a4paper, twocolumn, landscape, etc.\\
  \bigskip
  Other examples of commands: |\usepackage[]{},\textbf{},\copyright|
\end{frame}

\subsubsection{(Plain) text}
\begin{frame}[fragile]{Commands - (Plain) text}
  Plain text is easy, but \LaTeX\ makes simple things difficult: 
  \begin{itemize}
    \item \textbf{Bold} text is created using the command: |\textbf{}|
    \item \textit{Italized} text is created using the command: |\textit{}|
    \item Characters such as \'a, \`a and \^a are written as $\backslash$'a, $\backslash$`a and $\backslash$\^\/a respectively 
  \end{itemize}
  
  \bigskip
  
  And more difficult things easy:
  \begin{itemize}
    \item $20^{\circ}$C is written as |20$^{\circ}$C|
    \item |$\omega$| produces $\omega$ and |$\Omega$| produces $\Omega$
    \item |\footnote{}|\footnote{produces a footnote}
  \end{itemize}
\end{frame}


\subsubsection{Document structure}
\begin{frame}[fragile]{Document structure}
  You need to make a structure for your report. Use a hierarchy:
  \begin{itemize}
    \item |\chapter{<chapter name>}| (Only for report and book class)
    \item |\section{<section name>}|
    \item |\subsection{<subsection name>}|
    \item |\subsubsection{<subsubsection name>}|
    \item |\paragraph{<paragraph name>}|
    \item |\subparagraph{<subparagraph name>}|
  \end{itemize}
  
  Don't want numbered sections, use an asterix: |\section*{<section name>}|
  
\end{frame}

\subsection{Environments}
\begin{frame}[fragile]{Environments}
  \emph{Environments} are used to encapsulate information and are a container for text and are formatted according to a keyword:
  
  \begin{lstlisting}[basicstyle = \ttfamily\small]
\begin{figure}
 \centering
 \includegraphics[width=?]{LaTeX_usage}{
 \caption{A graph showing the increase of EEMCS-students using LaTeX.}
 \label{figure:latex_usage}
\end{figure}
  \end{lstlisting}

  \begin{lstlisting}[basicstyle = \ttfamily\small]
\begin{tabular}{l|c|c|c|}
& 2017 & 2018 & 2019\\
\hline
# of EEMCS-students using LaTeX & 3 & 21 & >9000\\
\end{tabular}
  \end{lstlisting}
\end{frame}


\subsubsection{Mathematics}
\begin{frame}[fragile]{Mathematics (1/2)}
  There are two environments for mathematics:
  \begin{itemize}
    \item Inline: |$...$|
    \item Or the environment|\begin{equation} ... \end{equation}|
  \end{itemize}
  \bigskip
  The latter offers more possibilities:
  \begin{columns}[t,onlytextwidth]
    \begin{column}{.65\textwidth}
      \begin{itemize}
        \item Multi-line equations
        \item |\begin{\split} ... \end{split}|
        \item Referencing it using |\ref{}|
     \end{itemize}
    \end{column}
    
    \begin{column}{.35\textwidth}
      \begin{equation*}
        \begin{split}
          A & = \frac{\pi r^2}{2} \\
          & = \frac{1}{2} \pi r^2
        \end{split}
      \end{equation*}
    \end{column}
  \end{columns}
\end{frame}

\begin{frame}[fragile]{Mathematics (2/2)}
  Within a mathematics environment many symbols can be used:\\
  |\omega| $= \omega$, |\Omega| $= \Omega$, |\pi| $= \pi$, |\pm| $= \pm$,\\
  |a^{b}| $= a^{b}$ and |a_{b}| $= a_{b}$\\
  \bigskip
  And default constructions can be used:\\
  |\frac{...}{...}| $= \frac{a}{b}$,\\ |\sqrt{...}| $= \sqrt{a}$,\\ |\int_{...}^{...}| $=\int_{a}^{b}$
\end{frame}

\subsubsection{Figures}
\begin{frame}[fragile]{Figures (1/2)}
  Graphics are loaded from the folder where the |.tex| file is located. Use the \emph{graphicx} package to manage images.\\
  \bigskip
  They be included in a |\begin{figure}[t/b/h]| environment using: |\includegraphics[width=.5\textwidth]{<file name>}|\\
  \bigskip
  Use |\caption{<description of image>}| to caption your image.\\
  Use |\label{fig:<keyword>}| to reference it in your text.
  
\end{frame}

\begin{frame}[fragile]{Figures (2/2)}
  \begin{columns}
    \begin{column}{.6\textwidth}
      Images can be:
			\begin{columns}[T]
				\begin{column}{.32\columnwidth}
					\begin{itemize}
						\item Scaled:
						\item Stretched:
						\item Rotated:
						\item Wrapped:
					\end{itemize}
				\end{column}
				
				\begin{column}{.7\columnwidth}
					|[scale=1.5]|\\
					|[width=3cm,height=4cm]|\\
					|[angle=45]|\\
					Use package \emph{wrapfig} with |\begin{wrapfigure}|
				\end{column}
			\end{columns}
      \bigskip
			\bigskip
      An overview of all images can be made using |\listoffigures|.
    \end{column}
		
    \begin{column}{.4\textwidth}
      \begin{figure}
        \includegraphics[width=.55\columnwidth, angle=35]{cutecat}
        \caption{A picture of a cute cat.}
      \end{figure}      
    \end{column}
  \end{columns}
\end{frame}


\subsubsection{Tables}
\begin{frame}[fragile]{Tables (1/2)}
  \LaTeX\ is good at many things, tables is not one of them...\\
  \bigskip
  \begin{columns}
    \begin{column}{.53\textwidth}
      \begin{lstlisting}
\begin{tabular}{m{7em}|c|c|c|}
  & 2017 & 2018 & 2019\\
  \hline
  \# of EEMCS-students using LaTeX & 3 & 21 & >9000\\
\end{tabular}
      \end{lstlisting}
    \end{column}
    \begin{column}{.53\textwidth}
      \begin{tabular}{m{7em}|c|c|c|}
         & 2017 & 2018 & 2019\\
        \hline
        \# of EEMCS-students using LaTeX & 3 & 21 & >9000\\
      \end{tabular}
    \end{column}
  \end{columns}
\end{frame}

\begin{frame}[fragile]{Tables (2/2)}
  There are however many options with regard to layout:
  \begin{columns}[T]
    \begin{column}{.75\textwidth}
      \begin{itemize}
        \item |\multicolumn{2}{|c|}{<cell contents>}|
        \item Coloured rows using |\usepackage{xcolor}| and |{\rowcolors{2}{gray!30}{gray!15}|
      \end{itemize}
    \end{column}
    \begin{column}{.25\textwidth}
      {\rowcolors{2}{gray!30}{gray!15}
      \begin{tabular}{|l|c|}
        \hline
        \multicolumn{2}{|c|}{Table header}\\
        \hline
        Cell1 & Cell 2\\
        Cell3 & Cell 4\\
        Cell5 & Cell 6\\
        Cell7 & Cell 8\\
        \hline
        
      \end{tabular}
      } %End of rowcolors
    \end{column}
  \end{columns}
        \bigskip
      An overview of all tables can be made using |\listoftables|
  
\end{frame}




\subsubsection{Lists}
\begin{frame}[fragile]{Lists}
  There are two types of lists:
  \begin{columns}[t]
    \begin{column}{.5\textwidth}
      \begin{itemize}
        \item Those with unnumbered items
        \item Created using: 
        \item[] |\begin{itemize}|
        \item[] |\item|
        \item[] |\end{itemize}|
      \end{itemize}
    \end{column}
    \pause
    \begin{column}{.5\textwidth}
      \begin{enumerate}
        \item And those with numbered items
        \item Created using: 
        \item[] |\begin{enumerate}|
        \item[] |\item|
        \item[] |\end{enumerate}|
        \item Which can contain many items
        \begin{enumerate}
          \item Which can be nested
          \begin{enumerate}
            \item Nestception
          \end{enumerate}
        \end{enumerate}
      \end{enumerate}
    \end{column}
  \end{columns}
\end{frame}


\section{Cross-referencing}
\frame{\sectionpage}


\begin{frame}[fragile]{Cross-referencing}
  Label an image/table/section, using: |\label{fig/tab/sec:<name>}|\\
  \bigskip
  And refer to it in your text:
  \begin{itemize}
    \item Use |\ref{fig/tab/sec:<name>}| to create a reference
    \item Use |\pageref{fig/tab/sec:<name>}| to refer to the page of the object
    \item More options using the \emph{hyperref} package:
    \begin{itemize}
      \item Clickable (hyper-)links
      \item Advanced PDF options
    \end{itemize}
  \end{itemize}
\end{frame}



\section{Referring to literature}
\frame{\sectionpage}

\begin{frame}[fragile]{Literature references - \LaTeX}
	Used if you need a few and quick references. Start it with: |\begin{thebibliography}{<number of references>}|
	
	And add bibliography items:
	\begin{lstlisting}
\bibitem{greenwade93}
	George D. Greenwade,
	The {C}omprehensive {T}ex {A}rchive {N}etwork ({CTAN}),
	1993,
	TUGBoat,
	342--351.
	\end{lstlisting}
	And after all |\bibitems| close the environment with |\end{thebibliography}|\\
\end{frame}



\subsection{BibTeX package}
\begin{frame}[fragile]{Literature references - Bib\TeX\ Package}
	For more and complex references use the \emph{Bib\TeX\/} package. Load using: |\usepackage{bibtex}|\\
	\bigskip
	\begin{block}{The .bib file}
	  \emph{Bib\TeX} utilises a separate file for referencing with extension |.bib|, a plain text file (edit with notepad). It contains the details on all references.
	\end{block}  
\end{frame}


\subsubsection{The .bib file}
\begin{frame}[fragile]{The .bib file - An example}
  \begin{lstlisting}[language=BibTeX]
@article{greenwade93,
  author  = "George D. Greenwade",
  title   = "The {C}omprehensive {T}ex {A}rchive {N}etwork ({CTAN})",
  year    = "1993",
  journal = "TUGBoat",
  volume  = "14",
  number  = "3",
  pages   = "342--351"
}
  \end{lstlisting}
\end{frame}

\begin{frame}{The .bib file - Entries \& Fields}
	\begin{block}{There are different types of citations (entries):}				
	\textbf{@article},\textbf{@book},@collectedbook,@conference,@electronic,@ieeetranbstctl,@inbook,\\
	@incollectedbook,@incollection,@injournal,@inproceedings,@manual,@mastersthesis,\\
	\textbf{@misc},@patent,@periodical,@phdthesis,@preamble,@proceedings,@standard,@string,\\
	@techreport,@unpublished
	\end{block}
	
	\begin{block}{Within an entry there are several (required) fields:}
	address,annote,author,booktitle,chapter,crossref,edition,editor,howpublished,\\
	institution,journal,key,month,note,number,organization,pages,publisher,school,\\
	series,title,type,volume,year
	\end{block}
\end{frame}

\begin{frame}[fragile]{The .bib file - URL's}
	Either use |\url| (requires \emph{hyperref} package) in \textit{howpublished},
	\\ or using the \emph{url} field.\\
	\bigskip
	
	An example of a reference with URL\nocite{wikibooks}:\\
% 	\bibliographystyle{IEEEtran}
% 	\bibliography{bibliography}
  \begin{thebibliography}{1}
  \bibitem{wikibooks}
     Wikibooks,
     "\textit{LaTeX/Bibliography Management --- Wikibooks{,} The Free Textbook Project}",
     2019,
     \url{https://en.wikibooks.org/w/index.php?title=LaTeX/Bibliography_Management&oldid=3584255},
     [Online; accessed 20-October-2019]
  \end{thebibliography}
\end{frame}



\subsection{Applying a reference in the text}
\begin{frame}[fragile]{Reference in text}
	To cite simply use |\cite{<cite_key>}| for both \LaTeX\ and Bib\TeX\/.\\
	\bigskip
	To include a \emph{bibliography} at the end use:
	\begin{lstlisting}
\bibliographystyle{<bibliography style>}
\bibliography{<name of .bib file>}		
	\end{lstlisting}
\end{frame}

\subsubsection{Bibliography styles}
\begin{frame}[fragile]{Bibliography styles - Plain}
	\begin{columns}
		\begin{column}{.2\columnwidth}
				\texttt{plain}
		\end{column}
		
		\begin{column}{.8\columnwidth}
			\begin{figure}%
				\includegraphics[width=.8\columnwidth]{BibtexStylesExPLAIN}%
				\label{fig:styleplain}%
			\end{figure}
		\end{column}
	\end{columns}
\end{frame}

\begin{frame}[fragile]{Bibliography styles - APA like}
	\begin{columns}
		\begin{column}{.2\columnwidth}
			\texttt{apalike}
		\end{column}
		
		\begin{column}{.8\columnwidth}
			\begin{figure}%
				\includegraphics[width=.8\columnwidth]{BibtexStylesExAPA}%
				\label{fig:styleapa}%
			\end{figure}
		\end{column}
	\end{columns}
\end{frame}

\begin{frame}[fragile]{Bibliography styles - IEEE Transactions}
	\begin{columns}
		\begin{column}{.2\columnwidth}
			\texttt{IEEEtran}
		\end{column}
		
		\begin{column}{.8\columnwidth}
			\begin{figure}%
				\includegraphics[width=.8\columnwidth]{BibtexStylesExIEEETRAN}%
				\label{fig:styleieeetran}%
			\end{figure}
		\end{column}
	\end{columns}
\end{frame}



\section{Using multiple files}
\frame{\sectionpage}

\begin{frame}[fragile]{Using multiple files for 1 document}
  \begin{block}{Input}
    |\input{epic_file.tex}| 
    \begin{itemize}
      \item Input content of file |epic_file.tex| directly
      \item Can be nested
    \end{itemize}
  \end{block}
  
  \bigskip
  
  \begin{block}{Include}
    |\include{epic_file.tex}| 
    \begin{itemize}
      \item Applies |\pagebreak| inserts the code and applies pagebreak again
      \item Perfect for combining chapters
      \item Cannot be nested
    \end{itemize}
  \end{block}
\end{frame}



\section{How to setup \LaTeX}
\frame{\sectionpage}

\begin{frame}[fragile]{How to 'install' LaTeX}
  \begin{columns}[t]
    \begin{column}{.4\textwidth}
      \LaTeX\ is plain-text which can be written in an \emph{editor}:
    \end{column}
    
    \begin{column}{.3\textwidth}
    The plain-text can be compiled using \LaTeX\ \emph{engines}:
    \end{column}
    
    \begin{column}{.33\textwidth}
      Additional functionality is applied using \emph{packages}. Can be downloaded using a \emph{manager}:
    \end{column}
  \end{columns}
  
  \begin{columns}[t]
    \begin{column}{.4\textwidth}
    	\begin{itemize}
		    \item \textbf{TeXworks} (Simple)
		    \item TeXnicCenter (Full editor)
		    \item TeXstudio
		    \item LaTeXila (Linux)
	    \end{itemize}
    \end{column}
    
    \begin{column}{.3\textwidth}
  	\begin{itemize}
	  	\item \textbf{pdf\LaTeX}
	  	\item \XeLaTeX\ (\LaTeX3)
	  	\item \LuaLaTeX\
	  \end{itemize}
    \end{column}
    
    \begin{column}{.33\textwidth}
      \begin{itemize}
	      \item \textbf{Mik\TeX\/} (Windows)
	      \item \TeX\ Live\\ (Unix/Linux/Windows)
	      \item Mac\TeX\ (Mac OSX)
      \end{itemize}
    \end{column}
  \end{columns}
	\bigskip
	Alternatively use \url{https://overleaf.com} which is all-in-one.
	\flushright\includegraphics[width=.3\textwidth]{overleaf}
\end{frame}



\section{How to get help with \LaTeX}
\begin{frame}{How to get help?}
	\begin{itemize}
		\item \href{http://en.wikibooks.org/wiki/LaTeX}{The \LaTeX\ Wikibook} for reference
		\item \href{http://tex.stackexchange.com/}{The \TeX\ Stack Exchange} for questions
		\item The instructors
		\item And remember: Google is your friend!
	\end{itemize}
\end{frame}

\end{document}
