Beamer Presentations: A Tutorial for Beginners (Part 3)—Blocks, Code, Hyperlinks and Buttons
Part 1 | Part 2 | Part 3 | Part 4 | Part 5
Author: Josh Cassidy (August 2013)
This five-part series of articles uses a combination of video and textual descriptions to teach the basics of creating a presentation using the LaTeX beamer package. These tutorials were first published on the original ShareLateX blog site during August 2013; consequently, today's editor interface (Overleaf) has changed considerably due to the development of ShareLaTeX and the subsequent merger of ShareLaTeX and Overleaf. However, much of the content is still relevant and teaches you some basic LaTeX—skills and expertise that will apply across all platforms.
In the previous post we looked at adding some basic content into our presentation. In this post we're going to look at adding some other types of content.
Blocks
One of the ways beamer
lets us display information on slides is using 'blocks'. To do this we use the block
environment:
\begin{block}{Block Title}
Lorem ipsum dolor sit amet, consectetur adipisicing elit,
sed do eiusmod tempor incididunt ut labore et
dolore magna aliqua.
\end{block}
At the end of the \begin{block}
command we simply enter the block's title in curly brackets. Then whatever we enter in between the \begin{block}
and \end{block}
commands, forms the content of the block. This is what it looks like:
There are quite a few variations of the block
environment that help us produce blocks for different purposes. The first is the alertblock>/code> environment which is similar to the
block
environment except its colour is red instead of blue:
\begin{alertblock}{Block Title}
Lorem ipsum dolor sit amet, consectetur adipisicing elit,
sed do eiusmod tempor incididunt ut labore et
dolore magna aliqua.
\end{alertblock}
Then there's the definition
environment which produces a standard blue block but with the title already specified as Definition:
\begin{definition}
A prime number is a number that...
\end{definition}
Next there's the example
environment which produces a green block with the title Example.
\begin{example}
Lorem ipsum dolor sit amet, consectetur adipisicing elit,
sed do eiusmod tempor incididunt ut labore et
dolore magna aliqua.
\end{example}
There is also a group of blocks that are especially useful for presenting mathematics; for example, the theorem
environment, the corollary
environment and the proof
environment:
\begin{theorem}[Pythagoras]
$ a^2 + b^2 = c^2$
\end{theorem}
\begin{corollary}
$ x + y = y + x $
\end{corollary}
\begin{proof}
$\omega +\phi = \epsilon $
\end{proof}
The theorem
and corollary
environments automatically put their content in italics. These two also allow us to add extra content to the block title in parenthesis by adding text into square brackets at the end of the \begin{...}
command. It's worth mentioning at this point that beamer
automatically loads the amsmath
package so you can add more complicated mathematics straight away.
Code
Now let's talk about adding code into slides. This is particularly important for any computer science related presentation. To do this we use the semiverbatim
environment. In order to use this environment on a frame, we need to add the fragile
option into the \begin{frame}
command. Now whatever text we enter in the environment will appear as written, except for the backslash, open curly bracket and close curly bracket characters, which will continue to behave as they normally would in LaTeX; therefore, if we want to print some code which includes these characters we need to add an extra backslash before each of them. Here's an example printing the code we used for the title slide:
\begin{frame}[fragile]
\frametitle{Including Code}
\begin{semiverbatim}
\\begin\{frame\}
\\frametitle\{Outline\}
\\tableofcontents
\\end\{frame\}
\end{semiverbatim}
\end{frame}
Hyperlinks and buttons
Finally, I want to discuss adding hyperlinks to our presentation. Before we can create any hyperlinks we need to tag the frames we want to link to using the \label
command; for example, we'll add a label to the contents frame, the columns frame and the pictures frame:
\begin{frame}
\label{contents}
...
Then we use the \hyperlink
command to insert a link:
\hyperlink{contents}{click here}
In the first set of curly brackets we enter the label of the target frame and in the second set we add the text that we want to be clickable. Now if we compile the document you'll see the text is now a clickable link.
Beamer also allows us to use buttons. To do this we simply add a button command into the second set of curly brackets. For example, we'll swap the "click here" text for the \beamerbutton
command and enter in curly brackets the text we want to appear on the button:
\hyperlink{contents}{\beamerbutton{contents page}}
Here are some other button commands we can use:
\hyperlink{columns}{\beamergotobutton{columns page}}
\hyperlink{pictures}{\beamerskipbutton{pictures page}}
\hyperlink{pictures}{\beamerreturnbutton{pictures page}}
The beamer
"go to" button, the beamer
"skip" button and the beamer
"return" button:
This concludes our second discussion on adding content to our presentation. In the next post we'll look at animating our presentations.
All articles in this series
- Part 1: Getting Started
- Part 2: Lists, Columns, Pictures, Descriptions and Tables
- Part 3: Blocks, Code, Hyperlinks and Buttons
- Part 4: Overlay Specifications
- Part 5: Themes and Handouts
Please do keep in touch with us via Facebook, Twitter or via e-mail on our contact us page.
Overleaf guides
- Creating a document in Overleaf
- Uploading a project
- Copying a project
- Creating a project from a template
- Using the Overleaf project menu
- Including images in Overleaf
- Exporting your work from Overleaf
- Working offline in Overleaf
- Using Track Changes in Overleaf
- Using bibliographies in Overleaf
- Sharing your work with others
- Using the History feature
- Debugging Compilation timeout errors
- How-to guides
- Guide to Overleaf’s premium features
LaTeX Basics
- Creating your first LaTeX document
- Choosing a LaTeX Compiler
- Paragraphs and new lines
- Bold, italics and underlining
- Lists
- Errors
Mathematics
- Mathematical expressions
- Subscripts and superscripts
- Brackets and Parentheses
- Matrices
- Fractions and Binomials
- Aligning equations
- Operators
- Spacing in math mode
- Integrals, sums and limits
- Display style in math mode
- List of Greek letters and math symbols
- Mathematical fonts
- Using the Symbol Palette in Overleaf
Figures and tables
- Inserting Images
- Tables
- Positioning Images and Tables
- Lists of Tables and Figures
- Drawing Diagrams Directly in LaTeX
- TikZ package
References and Citations
- Bibliography management with bibtex
- Bibliography management with natbib
- Bibliography management with biblatex
- Bibtex bibliography styles
- Natbib bibliography styles
- Natbib citation styles
- Biblatex bibliography styles
- Biblatex citation styles
Languages
- Multilingual typesetting on Overleaf using polyglossia and fontspec
- Multilingual typesetting on Overleaf using babel and fontspec
- International language support
- Quotations and quotation marks
- Arabic
- Chinese
- French
- German
- Greek
- Italian
- Japanese
- Korean
- Portuguese
- Russian
- Spanish
Document structure
- Sections and chapters
- Table of contents
- Cross referencing sections, equations and floats
- Indices
- Glossaries
- Nomenclatures
- Management in a large project
- Multi-file LaTeX projects
- Hyperlinks
Formatting
- Lengths in LaTeX
- Headers and footers
- Page numbering
- Paragraph formatting
- Line breaks and blank spaces
- Text alignment
- Page size and margins
- Single sided and double sided documents
- Multiple columns
- Counters
- Code listing
- Code Highlighting with minted
- Using colours in LaTeX
- Footnotes
- Margin notes
Fonts
Presentations
Commands
Field specific
- Theorems and proofs
- Chemistry formulae
- Feynman diagrams
- Molecular orbital diagrams
- Chess notation
- Knitting patterns
- CircuiTikz package
- Pgfplots package
- Typesetting exams in LaTeX
- Knitr
- Attribute Value Matrices
Class files
- Understanding packages and class files
- List of packages and class files
- Writing your own package
- Writing your own class