Lessons in LaTeX — Starting a presentation

Introduction

Greetings, friend! So far in our Lessons in LaTeX series, we’ve concentrated on creating a document. To do so, we grabbed an existing book template (the Legrand Orange Book) and started updating the graphics and fonts to suit our liking. While documents are a signature use of the software, LaTeX also gives PowerPoint a run for its money in terms of building presentation slide decks!

To be honest, I’ve never developed a slide deck in LaTeX, but I’ve always wanted to. So in this lesson, I’m going to grind through setting up my first slide deck and learn the ins and outs of modifying it to fit my needs.

Finding a template

Like other document types, there are many LaTeX templates for presentation slides decks. After sifting through the many templates found on the Overleaf, I found one that I liked — the Loewner Equation template. In order to work with in in MikTeX, I opened the template in Overleaf, clicked “Menu” in the upper left-hand corner, and then clicked “Source”. This downloaded all the necessary presentation files to my desktop in a convenient ZIP folder. Knowing the presentation files will not be compiled in the ZIP file, I made a new folder titled “presentation” on my Desktop, and copied over the files from the ZIP folder. Let’s try running the script, shall we?

Fixing the bugs: Font

After a few seconds, the main file, demo.tex, crashes due to an error regarding the fira-sans font package not being found. To fix this error, I opened the MikTeX console (Start > MikTeX > MikTeX Console), and clicked on Packages on the left-side menu. I then typed “fira” into the search bar; the first search result (“fira”) is a Fonts package — let’s give this a shot! Selecting the “fira” package, I also choose to “Retrieve from: Random package repository on the Internet”, and click the blue “+” sign to retrieve the package. This brings up a dialog box, in which I choose “OK” to install the packages.

Once I do that, another dialog box pops up showing the download and install process. Once completed, I close the window and re-run the .tex file in MikTeX — it progresses further this time, suggesting our fix worked!

Fixing the bugs: -shell-escape flag

Then we hit another snag: “! Package minted Error: You must invoke LaTeX with the -shell-escape flag.” To fix this error, we simply need to add the –shell-escape command at the end of the argument when the .tex file compiles. In the MikTeX window, I click on Edit > Preferences… > Typesetting tab.

Here, we can click on our current compiler (XeLaTeX), then click “Edit…” to see what kind of commands are already running. We can then click the blue “+”, and type in --shell-escape into the new text line, then hit Enter. Remember, we want this to run in the same format as before, so we also click the green up arrow to move our new command before the $fullname command. The final result is shown above; we then click OK > OK, then back to the MikTeX page. With these changes made, we try re-compiling the .tex file — it compiles with no other issues! Whoop whoop!

Verbage

Like any other language, in order to talk about something coherently, we need to use the same language LaTeX uses in building its documents. For instance, let’s take a look inside the main .tex file to get a feel for what’s going on.

Immediately, we start to see a generic type of repetition. While lines 1 – 11 are used to identify and define packages used by LaTeX, lines 13-16 define the information used on the title slide — things like presentation title, author, etc. But then under that, we see repeated sections that start with \begin{frame} and end with \end{frame}. From this, we can guess that each slide within our presentation is called a “frame” — terminology we’ll try to stick with moving forward. Furthermore, the title of each frame (slide) is defined by the subsequent tag \frametitle{Title here}.

Other than that, all the other code seems to be normal LaTeX code. Figures are still defined between the \begin{figure} and \end{figure} tags, bulleted lists are still defined between \begin{itemize} and \end{itemize} tags, and centered equations are defined between \begin{center} and \end{center} tags, where the equations themselves are defined between dollar signs ($).

Awesome! So once we get a feel for which files contain which information, everything should seem pretty readable. Let’s try to modify something!

Modifying the font

Color

As you’ve probably already seen, the font hierarchy for the presentation is a bit more complicated than the files used to make our Legrand Orange Book. Although every modification command is here, we just have to find it before we can use it. For instance, we can modify the color of the font by opening the file titled “beamercolorthememetropolis.sty”. Here, the word “color” is highlighted to remind us that this is the file we use to modify every aspect of color within the presentation.

Lines 36 and 37 define the colors of the normal text (the main text throughout the slides) and the “alerted” text — text like “Figure” in the caption of an image. Changing these font colors is easy — for instance, we can change the normal font color to gray by setting line 36 to: \setbeamercolor{normal text}{fg=gray!97} instead of black.

Font

Definitions for the fonts are located in a separate file, “beamerfontthememetropolis.sty” Similar to the color style file, the file name contains the word font (highlighted in bold) to remind us that this is where we can define font types throughout our presentation. Since we tried modifying the frame title in our last section, let’s again target the frame title font. Since we’re becoming familiar with the LaTeX verbage, we know we’re looking for the frametitle tag, which we find on line 35.

Within this line, the frame title font is defined by a font family (\Book), series (\scshape), and size (\Large). Similar to how we looked up the definition of colors in the previous section, we can look up the definition for the \Book font family on line 20. If we swap “Fira Sans” to “Times New Roman” (\newfontfamily\Book{Times New Roman}), save the font file, and re-compile demo.tex, we see that the title of each slide has now changed and the font of the (now gray) body text is still defined as Fira Sans:

Modifying the top banner

Modifying the top banner is a little bit more abstract. In the same style file (“beamercolorthememetropolis.sty”), we see that instead of directly assigning a color to an object (ex. font), things like “title” (line 25) and “frametitle” (line 32) are assigned a pallet. These color pallets are defined earlier in the file (lines 30-32):

\setbeamercolor{palette primary}{fg=mDarkRed, bg=black!2}
\setbeamercolor{palette secondary}{fg=white, bg=mDarkRed}
\setbeamercolor{palette quaternary}{fg=mDarkBrown}
\setbeamercolor{palette tertiary}{fg=white, bg=mMediumBrown}

where the pallete names are listed as “pallete primary”, “pallete secondary”, etc., and each pallete is defined by a foreground color (fg) and background color (bg). Furthermore, each pallete is defined using colors defined in lines 14-18.

For instance, the color scheme of the title of each frame (line 32) is defined by the secondary pallet (“pallete secondary”), which uses a white foreground (fg=white) color and a dark red background color (bg=mDarkRed). Although not initially defined, we’ve added the “dark red” color using a similar color encoding format as used in lines 14-18. Specifically, we define “dark red” as: \definecolor{mDarkRed}{HTML}{661100}, and placed the new definition on line 16.

Putting each of these steps together, we’ve made the following modifications:
line 16 –> \definecolor{mDarkRed}{HTML}{661100}
line 21 –> \setbeamercolor{palette secondary}{fg=white, bg=mDarkRed}
line 32 –> \setbeamercolor{frametitle}{parent=palette secondary}, which results in the following color change.

Conclusion

Whew! Round 1 in the battle to learn LaTeX presentations is over, and I think we’re doing pretty well! In this tutorial, we started with nothing except for an installation of MikTeX. We found a presentations template on Overleaf, downloaded the template, and debugged the code and packages to give us a running presentation file.

We then poked around inside the main .tex file, the font style file, and the colors style file to demonstrate how we can alter each of the style files to change the font style and color in the body, and also change the color of the frame title section. We also reviewed some new verbage and looked at the tags used to add figures, equations, and bulleted lists.

I know this has been helpful for me to get my hands dirty in building a presentation in LaTeX, and I hope you’ve found it helpful as well! Thank you for dropping by and learning with me. Feel free to visit my full list of articles, visit my homepage, or sign up for automatic updates!

Get new content delivered directly to your inbox.

Advertisement
%d bloggers like this: