未加星标

How to create presentations with Beamer

字体大小 | |
[开发(python) 所属分类 开发(python) | 发布者 店小二04 | 时间 2019 | 作者 红领巾 ] 0人收藏点击收藏

Beamer is a LaTeX package for generating presentation slide decks. One of its nicest features is that it can take advantage of LaTeX's powerful typesetting system and all the other packages in its ecosystem. For example, I often use LaTeX's listings package in Beamer presentations that include code.

Starting a presentation

To begin a Beamer document, enter:

\documentclass{beamer}

As you would with any other LaTeX document, add any packages you want to use. For example, to use the listings package, enter:

\usepackage{listings}

Place all content inside the document environment:

\begin{document}

Beamer documents are usually a sequence of frame environments. Frames that contain code should be marked fragile :

\begin{frame}[fragile]

Begin your frames with a title:

\frametitle{Function to Do Stuff} Testing your code before you present it

One of the worst feelings in the world is giving a talk and realizing, as you walk through the code, that there is a glaring bug in it―maybe a misspelled keyword or an unclosed brace.

The solution is to test code that is presented. In most presentation environments, this means creating a separate file, writing tests, then copying and pasting.

However, with Beamer, there is a better way. Imagine you have a file named do_stuff.py that contains code. You can write tests for the do_stuff.py code in a second file, which you call test_do_stuff.py , and can exercise it with, say, pytest . However, most of the lines in do_stuff.py lack pedagogic value, like defining helper functions.

To simplify things for your audience, you can import just the lines you want to talk about into the frame in your presentation :

\lstinputlisting[

language=python,

firstline=8,

lastline=15

]{do_stuff.py}

Since you will be talking through those lines (from 8 to 15), you don't need any other content on the slide. Close the frame:

\end{frame}

On the next slide, you want to show a usage example for the do_stuff() function you just presented:

\begin{frame}[fragile]

\frametitle{Calling Function to Do Stuff}

\lstinputlisting[

language=Python,

firstline=17,

lastline=19

]{do_stuff.py}

\end{frame}

You use the same file, but this time you show the lines that call the function. Finally, close the document:

\end{document}

Assuming you have an appropriate Python file in do_stuff.py , this will produce a short two-slide presentation.

Beamer also supports necessary features such as progressive revelation, showing only one bullet at a time to prevent the audience from being distracted by reading ahead.": \pause inside a list will divide bullets into pages:

\begin{frame}

Remember:

\begin{itemize}

\item This will show up on the first slide. \pause

\item This will show up on the

second slide, as well as the preceding point. \pause

\item Finally, on the third slide,

all three bullets will show up.

\end{frame}

Creating handouts My favorite feature in Beamer is that you can set it to ignore everything outside a frame with \documentclass[ignorenonframetext]{beamer} . When I prepare a presentation, I leave off the top (where the document class is declared) and auto-generate two versions of it: one with Beamer that ignores all text outside any frame, which I use for my presentation, and one with a header like:

\documentclass{article}

which generates a handout―a PDF that has all the frames and all the text between them.

When a conference organizer asks me to publish my slides, I include the original slide deck as a reference, but the main thing I like people to have is the handout, which has all the explanatory text that I don't want to include on the slide deck itself.

When creating presentation slides, people often wonder whether it's better to optimize their materials for the presentation or for people who want to read them afterward. Fortunately, Beamer provides the best of both worlds.

Topics

Tools

About the author Moshe Zadka

Moshe has been involved in the linux community since 1998, helping in Linux "installation parties". He has been programming Python since 1999, and has contributed to the core Python interpreter. Moshe has been a DevOps/SRE since before those terms existed, caring deeply about software reliability, build reproducibility and other such things. He has worked in companies as small as three people and as big as tens of thousands -- usually some place around where software meets system administration...

More about me

Learn how you can contribute

本文开发(python)相关术语:python基础教程 python多线程 web开发工程师 软件开发工程师 软件开发流程

分页:12
转载请注明
本文标题:How to create presentations with Beamer
本站链接:https://www.codesec.net/view/628351.html


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 开发(python) | 评论(0) | 阅读(39)