Powered by Blogger.

Presentation slides with LATEX on Ubuntu

Tuesday, October 2, 2012

A. Installation of LATEX and other required components

Open a terminal window and type the following commands.

$ sudo apt-get update 
$ sudo apt-get install texlive-full gedit-latex-plugin texlive-fonts-recommended 
latex-beamer texpower texlive-pictures texlive-latex-extra texpower-examples 
imagemagick

 Your LATEX installation with Beamer front end should be ready to work now.

B. How to start with LATEX

I am going to use GEDIT text editor here. Let's say our file name is "test.tex" ("tex" is the file extension used by LATEX). Type the following in your terminal.

$ gedit test.tex &

C. A simple LATEX code

Following code will create a simple presentation in LATEX. Just copy and paste the code in to your 'test.tex' file. Concept is more similar to HTML. Just go through the lines with comments, hopefully you will be able to understand how to modify the code based on your requirement.


\documentclass[compress]{beamer} %this is to use copressed header from the template
\usepackage{beamerthemeshadow} %our theme, later you can change it

% editing header
\setbeamertemplate{headline}
{
  \leavevmode%
  \hbox{%
  \begin{beamercolorbox}[wd=.5\paperwidth,ht=2.25ex,dp=1.8ex,leftskip=1em,left]{section in head/foot}%
    \usebeamerfont{subsection in head/foot}\hspace*{5ex}\insertsectionhead
  \end{beamercolorbox}%
  \begin{beamercolorbox}[wd=.5\paperwidth,ht=2.25ex,dp=1.8ex,left,leftskip=1em]{subsection in head/foot}%
    \usebeamerfont{section in head/foot}\insertshorttitle\hspace*{2ex}
  \end{beamercolorbox}}%
  \vskip0pt%
}

% editing footer
\setbeamertemplate{footline}
{
  \leavevmode%
  \hbox{%
  \begin{beamercolorbox}[wd=.5\paperwidth,ht=2.25ex,dp=1ex,right]{author in head/foot}%
    \usebeamerfont{author in head/foot}\insertshortauthor\hspace*{2ex}
  \end{beamercolorbox}%
  \begin{beamercolorbox}[wd=.5\paperwidth,ht=2.25ex,dp=1ex,right]{date in head/foot}%
    \usebeamerfont{date in head/foot}\insertshortdate{}\hspace*{2em}
    \insertframenumber{} / \inserttotalframenumber\hspace*{2ex} 
  \end{beamercolorbox}}%
  \vskip0pt%
}

%enable numbering captions for the images
\setbeamertemplate{caption}[numbered]

%begining of the doc
\begin{document}

 \title{Presentation Title}  
 \author{Author Name}
 \date{October 2, 2012} %specify the date, if you want the current date use this, \date{\today}

 %title page
 \begin{frame}
 \titlepage
 \end{frame}

 %ToC page
 \begin{frame}
 \scriptsize
 {
  \frametitle{Table of contents}
  \tableofcontents
 }
 \end{frame} 

 %use sections for main headings
 \section{Section 1}
  
 %use subsection for subheadings
 \subsection{Section 1.1}
 \begin{frame}%create frame for each sldie
  \frametitle{Section 1.1} 
  \begin{itemize}%to have bulleted item list
   \item Item 1
    \begin{itemize}%sub bulleted items
     \item Item 1.1
    \end{itemize}
   \item Item 2
    \begin{itemize}
     \item Item 2.1
     \item Item 2.2
     \item Item 2.3
    \end{itemize}
   \item Item 3
  \end{itemize}
 \end{frame}

 \subsection{Section 1.2}
 \begin{frame}
  \frametitle{Section 1.2} 
  \begin{figure}
   \includegraphics[scale=0.3]{ubuntu} 
   \caption{Caption 1}
  \end{figure}
 \end{frame}
  
 \subsection{Section 1.3}
 \begin{frame}
  \frametitle{Subsection 1.3}
  \begin{columns}%columnize the page content
   \column{.5\textwidth}%one column is half of the text width of the slide
   \begin{figure}
    \includegraphics[scale=0.2]{ubuntu}
    \caption{Caption 2}
   \end{figure}
   \column{.5\textwidth}
   \begin{figure}
    \includegraphics[scale=0.2]{ubuntu}
    \caption{Caption 3}
   \end{figure}
  \end{columns}
 \end{frame}

 \section{Section 2}
 
 \begin{frame}
  \frametitle{Section 2}
  Section texts can be typed here. If you want to \textbf{Bold} use this.%bolding text
  To \underline{Underline} use this.
  To \emph{Emphasis} use this. %text will change to eirther Italic or normal based on the present state
 \end{frame}

 \section{Section 3}

 \subsection{Section 3.1}
 \begin{frame}
  \frametitle{Section 3.1}
  \begin{enumerate}%numbered list
   \item Item 1
    \begin{itemize}%bulleted list
     \item Item 1.1
     \item Item 1.2
    \end{itemize}
   \item Item 2
   \item Item 3
   \item Item 4
   \end{enumerate}
 \end{frame}

 \subsection{Section 3.2}
 \begin{frame}
  \frametitle{Section 3.2}
  \begin{itemize}
   \item Item 1
   \item Item 2
  \end{itemize}
  
  \begin{columns}%place 3 figures in the same slide
   \column{.5\textwidth}
   \begin{figure}
    \includegraphics[scale=0.3]{ubuntu}
    \caption{Caption A}
   \end{figure}
   \column{.5\textwidth}
   \begin{figure}
    \includegraphics[scale=0.1]{ubuntu}
    \caption{Caption B}
   \end{figure}
   \begin{figure}
    \includegraphics[scale=0.1]{ubuntu}
    \caption{Caption C}
   \end{figure}    
  \end{columns}
 \end{frame}

 \subsection{Section 3.3}
 \begin{frame}
  \frametitle{Section 3.3}
  \begin{columns}
   \column{.5\textwidth}
   \begin{itemize}
    \item Item a
    \item Item b
    \item Item c
   \end{itemize}
   \column{.5\textwidth}
   \begin{figure}
    \includegraphics[scale=0.2]{ubuntu}
    \caption{Caption}
   \end{figure}
  \end{columns}
 \end{frame}

 \begin{frame}
   {\Huge
     \vspace {0.15\textwidth}
     \begin{columns}[ccc]
       \begin{column}{0.3\textwidth}
       \end{column}
       \begin{column}{0.3\textwidth}
        \text{Thank you!}
       \end{column}
       \begin{column}{0.3\textwidth}
       \end{column}
     \end{columns}
   }
   \vspace {0.025\textwidth}
   \begin{center}
   {\huge Q\&A}
   \end{center}
 \end{frame}

\end{document}
 

Note: Your images should be in the same location with the 'test.tex' file. Later you can modify that. Pictures are recommended to be in the '.ps' format. Picture I used is 'ubuntu.ps'. So to run the code without any errors you should have a picture called 'ubuntu.ps' in the same location of 'test.tex'. Here is my file.

D. Let's run your LATEX code and create a PDF.

Paste and save the code in to 'test.tex' file. Switch back to terminal and run the following code.

$ gedit test.tex &
$ latex test.tex && dvips test.dvi && ps2pdf test.ps

This is how you can install "dvips" and "ps2pdf" if it is not installed in your box.

$ sudo apt-get install dvips ps2pdf

Now your PDF file of the presentation should be ready.