We can use the power of latex to generate nice-looking slides for presentation. In this article, I am going to write my experience on how can we create slides using latex. I am using the Beamer document for that purpose, which is a popular template for presentation.
Preparation
We need latex to be installed in our system and install the package Beamer and other additional packages required. I have prepared a docker image that has latex preinstalled, including additional useful packages (texlive-full).
The latex template can be downloaded/cloned from
https://github.com/krishna444/LatexTemplate
After checkout, we can continue working on this project.
Implementation
The PDF file is generated using the following command. The MAIN_FILE is the tex file that needs to be compiled to generate the PDF file.
File: BuildLatex.sh
#!/bin/bash
IMAGE=krishna444/latex:debian
MAIN_FILE=source/Sample.tex
OUTPUT_DIR=output
mkdir -p $OUTPUT_DIR
COMMANDS="pdflatex -output-directory=$OUTPUT_DIR $MAIN_FILE"
sudo docker run --rm -it --net=none -v $PWD:/source $IMAGE /bin/bash -c "$COMMANDS"
sudo chown -R $USER:$USER $OUTPUT_DIR
Sample latex file to generate slides
\documentclass{beamer}
\usepackage{comment}
%set background
\setbeamertemplate{background}{\includegraphics[width=\paperwidth,height=\paperheight]{source/images/background.png}}
%align title on the center
\setbeamertemplate{frametitle}[default][center]
%skip title 0.3cm vertically.
\addtobeamertemplate{frametitle}{\vskip 0.3cm}{}
%lots of themes available
\usetheme{Hannover}
%\usetheme{Boadilla}
%\usetheme{Rochester}
%\usetheme{PaloAlto}
%\usetheme{Madrid}
%title
\title{COTS : Introduction}
%\subtitle{Lets experiment on COTS}
\author{Prepared by: Krishna Paudel}
\institute{Institute}
\date{\today}
\begin{document}
%start adding frames where
\begin{frame}
\titlepage
\end{frame}
%Table of contents
\begin{frame}
\frametitle{Outline}
\tableofcontents
\end{frame}
%define styles for xml or json
\lstdefinestyle{XMLStyle}{
language=XML,
basicstyle=\ttfamily\small,
commentstyle=\color{blue},
keywordstyle=\color{red},
stringstyle=\color{purple},
frame=single,
breaklines=true,
breakatwhitespace=true,
tabsize=2,
}
\lstdefinestyle{json}{
basicstyle=\small\ttfamily,
%numbers=left,
numberstyle=\tiny,
stepnumber=1,
numbersep=8pt,
showstringspaces=false,
breaklines=true,
frame=single,
backgroundcolor=\color{gray!10},
morestring=[b]`,
morestring=[b]',
stringstyle=\color{blue},
commentstyle=\color{olive},
keywordstyle=\color{purple},
}
\begin{comment}
Comments can be placed here, latex will simply ignore these.
\end{comment}
% Introduction Section (displayed in table of content)
\section{Introduction}
\subsection{This is introduction}
\begin{frame}
\frametitle{Title}
\begin{itemize}
\item item1
\item item2
\item item3
\item item4
\end{itemize}
\end{frame}
\section{Background}
%include some external tex file
\input{source/frames/background.tex}
.
.
.
/end{document}
Some useful tips:
How to include images?
\centering
\includegraphics[width=10cm,scale=0.5]{source/images/block-diagram.png}
How to add hyperlink?
\usepackage{hyperref}
\usepackage{xcolor}
\href{https://sample.com}{\color{blue}{Link}}
How to display in multicolumns?
\begin{columns}[t]
\column{.5\textwidth}
\centering
\includegraphics[width=5cm,height=7cm]{image1.png}
\column{.5\textwidth}
\centering
\includegraphics[width=6cm,height=7cm]{image2.png}
\end{columns}
Using verbatim in frame
Verbatim does not work in frame. For that, we have to start frame like this
\begin{frame}[fragile]
Also to include styles in frame, we need fragile option in the frame.
\begin{frame}[fragile]
\begin{lstlisting}[style=XMLStyle]
<xml></xml>
\end{lstlisting}
How to create table in Latex?
\centering
\begin{table}
\resizebox{\textwidth}{!}{
\begin{tabular}{|l|l|}
\hline
\textbf{Name} & \textbf{Description} \\
\hline
Row 1 & \textit{This is Row 1} \\
Row 2 & \textit{This is Row 2} \\
\hline
\end{tabular}
}
\caption{Table Title}
\end{table}
Display content in multiple colums
\begin{multicols}{2}
[Content]
\end{multicols}
Rotate Text in Latex
\usepackage{animate}
\rotatebox{5}{\textbf{\LARGE Thank YOU!}} %rotate by 5 degrees
\rotatebox{15}{\textbf{\LARGE Thank YOU!}} %rotate by 15 degrees
\rotatebox{25}{\textbf{\LARGE Thank YOU!}} %rotate by 25 degrees
\rotatebox{45}{\textbf{\LARGE Thank YOU!}} %rotate by 45 degrees