# More LaTeX and Beamer Tips

Following my earlier posts Top 5 Beamer Tips and Fine-Tuning Spacing in LaTeX Equations I offer four further tips that I’ve been using over the last few months.

## 1. Platform-independent specification of paths

I use both Windows and Mac machines and want my LaTeX files to run equally well on both. The only difficulty arises when a file is included from another directory (usually a PDF or jpeg file or a program listing). If the file name is specified relative to the current location then forward slash syntax can be used and works on both Mac and Windows. For example

\includegraphics[width = 8cm]{../figs/fig1.pdf}


However, if files are being pulled in from many different directories it can be tedious to specify relative paths and absolute paths are preferable. The problem is that the home directory is system-dependent. My solution is to use the ifplatform package as follows:

\usepackage{ifplatform}
...
\ifwindows\def\home{d:/}\else\def\home{/Users/nick/}\fi
%              Windows            Mac or Linux
...
\includegraphics[width = 8cm]{\home/tex/figs/fig1.pdf}


The \ifwindows construct sets up \home, which is then used as the prefix to the paths of the files to be included. (I initially tried using \home{~} for the Mac, but could not find a way of making this work, since LaTeX interprets the tilde as a hard space.)

## 2. Spacier Lists

If a Beamer slide consists mostly of a list and has lots of space below the list it can aid readability if the list is opened up a little, by increasing the spacing between items. This can be done as follows:

\begin{itemize}

\item
...

\end{itemize}


## 3. Code listings

The standard verbatim environment does not look very good in Beamer, as the font it uses is rather thin. I prefer to use the Verbatim environment provide by fanycvrb, which allows me to customize the font style and color:

\usepackage{fancyvrb}
\begin{Verbatim}[fontseries=b,formatcom=\blue]
...
\end{Verbatim}


This example uses a bold font in blue. Lots of other options are available for customizing the way the Verbatim environment is rendered.

In Emacs, with the RefTeX package, the command reftex-toc produces a table of contents for a LaTeX document, allowing navigation by sectional unit. By default, this command does not know about Beamer. You can tell reftex-toc about Beamer frames by adding the following to your .emacs, after (require 'reftex):

  (setq reftex-section-levels
(append '(("begin{frame}" . -3) ) reftex-section-levels))


This works even if the frame title is set with the \frametitle command.

# Top 5 Beamer Tips

Here are my top 5 tips for using Beamer, the popular LaTeX package for producing slides.

I’ve seen hundreds of talks with slides prepared in Beamer. I’ve yet to see anyone use the navigation symbols that Beamer puts at the bottom right-hand corner of the screen. These should be turned off with

\setbeamertemplate{navigation symbols}{}


### 2. Extra Slides

If you include extra slides at the end of your talk, you can stop them affecting the page count (usually shown in the footer) as follows:

\usepackage{appendixnumberbeamer}
...
\appendix
\begin{frame}{First Extra slide}
...


The appendixnumberbeamer package might not be included in your LaTeX distribution, in which case you can download it from CTAN.

### 3. References

You can include references in your slides using the following code, best placed after \appendix:

\begin{frame}[allowframebreaks]{References}
\def\newblock{}
\bibliographystyle{plain}
\bibliography{mybib}
\end{frame}


### 4. Sections

In a longer talk it can be useful to break the talk into sections and produce an outline slide at the start of each section. This can be done by putting in the preamble the code

\setbeamerfont{myTOC}{series=\bfseries,size=\Large}
\AtBeginSection[]{\frame{\frametitle{Outline}%
\usebeamerfont{myTOC}\tableofcontents[current]}}


and then typing \section[short_title]{long_title} between frames, where short_title is used for the headline (the line at the top of the screen that can contain various types of information, intended to help the audience know where you are in the talk). In this code I have increased the size of the font used for the outline and made it bold. If you don’t want the headline it can be turned off with

\setbeamertemplate{headline}{}


### 5. Columns

A good way to line up graphics side by side, especially if they are of different heights, is with Beamer’s columns environment:

\begin{columns}[c] % Columns centered vertically.
\column{5.5cm}     % Adjust column width to taste.
\includegraphics ...
\column{5cm}
\includegraphics ...
\end{columns}