Use AI to Generate Beautiful PDF Presentations via LaTeX and Overleaf

Use AI to Generate Beautiful PDF Presentations via LaTeX and Overleaf
AI generates LaTeX, which Overleaf turns into a PDF, which can be used for presentations
"It's not nearly as scary as the title makes it sound",

This post is not for everyone. If you are afraid of using a LaTeX editor or of even the word “code,” catch me on the next post or go read the one posted earlier on a simpler method. But if you want to learn how to create a particularly beautiful PowerPoint or a PDF presentation from a Large Language Model, this post is for you. Also, I am fully aware that there are “CustomGPTs” that purport to create PowerPoint slides for you. They work more or less but they rely on third party apps that may at some point require payment and that do not necessarily protect your privacy.  The “Don’t Reinvent the Wheel” department here at legaled.ai has yet to find one of these CustomGPTs that I like. The method I outline here can be free and does not require you to sacrifice privacy. Moreover, familiarity with how to use large language models to produce structured outputs such as LaTeX liberates you to produce many more derivative products for use in study, teaching, and scholarship.

Quick Conceptual Overview

Here is the workflow this blog entry envisions. If you'd prefer to listen to the main ideas rather than wend your way through the blog, however, here's a link to a really good synthetic podcast that sets forth the big picture.

  1. Presentation creation
    1. Use AI to go from your ideas or text to a hierarchical outline.
    2. Render that outline as "LaTeX" code. (often steps 1a and 1b are combined)
  2. PDF creation
    1. Create a free Overleaf account
    2. Set up Overleaf
    3. Copy the LaTeX code from the AI to an Overleaf file
    4. Use Overleaf to convert the LaTeX code into PDF slides
    5. Download the PDF
  3. Display of the Presentation
    1. Use a PDF viewer (Preview, Acrobat) to display the PDF slides or ...
    2. Use a program to convert the PDF slides into a PowerPoint pptx file and use PowerPoint to display the slides
      1. That program can either be an online service like smallpdf or ...
      2. Adobe Acrobat can convert the slides to a PowerPoint pptx file

Presentation Creation

Query and a generically formed output

The first step is very similar to that outlined in a previous blog entry. You give the AI material and ask it to create a hierarchical outline suitable for a slide presentation. You don't have to be as particular as discussed in the prior blog entry about the exact format of the response. Here's a perfectly reasonable query.

My AI produces the following. Your AI may produce something else. It really doesn't matter for present purposes. What matters is that, conceptually, it is a hierarchical outline, which is essentially what a classic PowerPoint or other presentation is.

Converting to LaTeX

We now want to tell the large language model to convert its response into LaTeX code. LaTeX is a typesetting system widely used in the sciences for creating high-quality technical documents. Renowned for its precision and ubiquity in fields like mathematics, physics, and computer science, it provides a long-standing, robust framework for producing professional publications.

Here's what LaTeX code looks like.

LaTeX is what came before "WYSIWYG," what you see if what you get. Notice that it does not look like Microsoft Word (or for the geriatric set, WordPerfect) or other modern text editors. Instead of, for example, a bullet point that looks like a bullet point, there is the code \item that will, depending on various settings, produce a bullet point or other marker symbol. Instead of visually creating a new slide as you might do were you editing in Powerpoint or Google Slides, you encapsulate the material for a frame in \begin{frame} and \end{frame}. There is always a "prefix" to LaTeX code that essentially sets up the default values for how the code is to be interpreted and the output rendered.If all this seems complicated and alien, I get it. But, as with many things, it's not that hard once you get used to it and there are many compensations for giving up the immediate visual appeal of today's WYSIWYG editors.

Here's the prompt I use to perform the conversion.

Take your last response and convert into a beamer latex presentation. Here is the prefix I want you to use.
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fontspec}
\usepackage{unicode-math}
\setmainfont{Open Sans}
\setsansfont{Roboto}
\setmonofont{Roboto Mono}
\usetheme{Madrid} 
\setbeamerfont{frametitle}{size=\large, series=\bfseries}
\setlength{\abovedisplayskip}{0pt} 
\setlength{\belowdisplayskip}{0pt} 
\addtobeamertemplate{frametitle}{\vspace*{2pt}\raggedright}{}
\setbeamertemplate{navigation symbols}{\insertslidenavigationsymbol\insertframenavigationsymbol\insertsubsectionnavigationsymbol\insertsectionnavigationsymbol}
\usepackage{amsmath,amsfonts,amssymb}
\usepackage{hyperref}
\usepackage{pdfcomment} 
Do not change this prefix at all. You can use telegraphic style when needed to condense lines of the output but do not make it cryptic. You can include speaker notes as desirable. Make absolutely sure to escape ampersands and other special latex characters. Also, go through your response to make sure that all directives are symmetrically enclosed in curly braces or square braces. A major source of problems is when you do things like this {itemize>. That breaks the compiler. Put your output in chat, not an artifact or canvas as I do not want to edit it here.

After a few moments, the AI responds with LaTeX code. Here's a screen shot of how it begins. I've placed a copy of the full raw response here.

The AI's work is done for now. Just leave your AI window open. We next want to go from LaTeX to PDF. And for that, we need a lovely service called Overleaf, which has turned dealing with LaTeX from the challenges of a decade ago to a perfectly reasonable experience.

PDF Creation

Creation of an Overleaf account

There are many ways to generate a PDF out of LaTeX code. One of the simplest is to use Overleaf. To do so, you will need a free Overleaf account. Here's the friendly sign up page. Nothing scary.

Follow the standard 2025 protocols for creating an account on web services and sooner or later you should get to here:

You could, of course, learn LaTeX with a tutorial. And there are hundreds of YouTube videos, books, and web resources on using LaTeX. This is an advantage of a system that has been around for decades and has millions of users across the globe. My conceit, however, is that you can skip all that and rely on AI to produce your LaTeX. You will need to know a few things to handle errors, but this blog post is going to identify the most common problems.

Set up Overleaf

Create a Project

Overleaf thinks in terms of Projects, which are very similar to the folders and directories you have been using since the dawn of the microcomputer. So once you have Overleaf in front of you, press the Create a new project button with a "blank template." Overleaf is going to ask you for the name of the Project. Name it the same way you would name a directory. I'm going to call mine "AIForLegalEd"

Again, if all goes well, you should see something like the image below on your screen. You will notice three panels. The left panel is kind of like a file directory. Right now, it has just one file, main.tex, which is what it names your first file by default. The filename is highlighted, meaning that it is the file with which you are currently working. See the three vertical dots next to the file name? That lets you perform basic file operations like renaming, downloading or trashing. The middle panel contains the LaTeX code associated with the active file on the left. Overkleaf stuck some code in by default when it created the project and its default main.tex file. Don't worry about it. We're basically going to ignore it. Also notice there's a little toggle above the middle panel "Code Editor|Visual Editor". We are going to leave that in Code Editor mode for now, but nothing will explode if you experiment and press Visual Editor.

The right panel contains a preview of what your PDF will look like. Note: it is NOT synced automatically with the middle panel. If I edit in the middle panel to change the title of the document to "The Unbelievable Costumes of The Gilded Age," the right panel will remain the same. (You don't need to "save" your work in the middle panel. Like many modern products, Overleaf auto-saves what you've done. The results live in The Cloud.)

Tweak the Compiler

Now for the scary part. We have to tweak one setting in Overleaf so that the fonts look good by the time we get to PowerPoint. You need to change the LaTeX compiler from its default value of pdfLaTeX to XeLaTeX. Just go to the menu button on the top left of the Overleaf window (it says "Menu") and you should see something like this. You want to check the XeLaTeX button. I hope that isn't too scary.

See, that wasn't so bad.

Creating a new LaTeX file

We need to create a new file that will house our LaTeX code. To do this, I'm going to click that little icon at the top left of the left panel of our Overleaf window.

Overleaf will ask us to name the file, which we do. I am naming mine "Mahmoud v Taylor slides". Once the file is created (instantly), you then need to select that file as the one you are working on. So click on the name of the file, which you can see here as Mahmoud v Taylor slid... (the rest got cut off).

Copy and Pasting the LaTeX from the AI to Overleaf

Once you select Mahmoud v. Taylor slides as the active file, your middle panel should be blank. Don't worry that the right panel hasn't changed yet. That's normal. It's still showing the last thing you successfully compiled and will remain that way until you try to compile something new. That new blank window in the middle is where we are going to paste the code snippet that Gemini (or another AI) provided. So go back to your AI and press the copy button in the LaTeX code snippet it produced or just use conventional copy commands in the AI window. Then paste the results into that middle window.

At the end of the pasting, you should see something like this in the middle panel of the Overleaf editor. Note: if there is a %%% in front of the \documentclass{beamer} line, get rid of the %%%. Failure to do so will result in an unbelievable cascade of error messages when you try to compile. LaTeX documents must being with \documentclass{something}. The reason what we are producing today are often called "Beamer Presentations" is that "beamer" is the documentclass used by LaTeX for this purpose.

Use Overleaf to convert the LaTeX code into PDF slides

Manual debugging before compiling

Even before I attempt to compile the LaTeX code and render a PDF, I scroll through the LaTeX code inside of Overleaf. We are hunting for anything with a pink highlight (bad) or a red circle next to the line number. As it happens, I was fortunate and there weren't many such warnings in my code. I will deliberately sabotage a line of code, however, so you can see what to look out for.

The red circle and the pink highlight are Overleaf's way of telling you your LaTeX code is defective. And neither LaTeX nor Overleaf are, at present, particularly forgiving. You want to try to fix obvious errors before you go any further. Here, and as is frequently the case with AI-generated LaTeX, the fix is simple. Do you see that we have \end{itemize> right above the pinked line. The curly brace on the left is not properly matched by an angle bracket on the right. We have asymmetric bracketing. The fix is easy. Just turn the > into a }. You can type directly in the code window, so this is easy.

I'll show you the other most common error.

You might not see any obvious problem with the code. And what does "undefined control sequence" mean? You might be getting terrified at this point and thinking this is all too complicated. Fear not.

The good news is that most AIs have been extensively trained on LaTeX. Its ubiquitous use in the sciences and disciplines other than law has assured this. So when you have LaTeX problems, just ask AI for help. I find that it diagnoses the problem successfully almost all the time.

This latex code is giving me an undefined control sequence error. What is the problem? How do I fix it? begin{frame}
\frametitle{Key Quotations - Majority Opinion (Alito, J.)}
\begin{itemize}
    \item \blockquote{"A government burdens the religious exercise of parents when it requires them to submit their children to instruction that poses 'a very real threat of undermining' the religious beliefs and practices that the parents wish to instill."}
    \item \blockquote{"Like the compulsory high school education considered in \textit{Yoder}, these books impose upon children a set of values and beliefs that are 'hostile' to their parents' religious beliefs."}
    \item \blockquote{"When a law imposes a burden of the same character as that in \textit{Yoder}, ... strict scrutiny is appropriate regardless of whether the law is neutral or generally applicable."}
\end{itemize}
\end{frame}

AI tells me what the problem is and how to fix it. It's mostly that pesky ellipsis in the Alito quote. We probably should have told AI in the original prompt to make sure to handle ellipses properly, as this is a common failing.

Two things not to worry too much about are red dots and yellow triangles. See the red dots under code such as the one you see here under Yoder? That's just a sign that the Overleaf spell checker has not studied American Constitutional Law and is thus unaware that Yoder is part of a case name and not a spelling failure. Here's an example of a yellow triangle (and a tooltip that appears when I hover over it.)

This is a common (and annoying) warning that it may be challenging to typeset a particular part of the slide properly. In my experience, Overleaf is usually smart enough to figure out a solution to this problem. Don't worry about it unless the output is obviously messed up.

Compiling

With all the obvious LaTeX problems resolved, we now pray to our Overleaf masters and press the green "Recompile" button atop the right panel. If all goes well, we get a beautiful PDF slide show. Like this.

If it doesn't work for you the first time and you get horrifying error messages, do not panic. It is usually one of a few things that can easily be fixed. I'm going to conclude this blog post with a debugging discussion.

Notice that we can iterate this process and correct issues with the PDF. We accomplish this by doing some light editing within the middle panel's LaTeX code if things aren't the way we want them. For example, Gemini left placeholders on the title slide. Plus, the title was too elaborate. I can go back to the middle editing panel and put in the relevant information.

\title{\textit{Mahmoud v. Taylor}}
\subtitle{A New Era for Free Exercise in Public Schools}
\author{Seth J. Chandler}
\institute{University of Houston Law Center}
\date{\today}

I now press the Recompile button again and get a new title slide.

You can iterate between editing of the middle panel and seeing the results of recompilation in the right until the document meets your requirements. If you need to make massive changes, however, you may want to go back to the AI, tell it what it did wrong, and ask it to take a first stab at fundamental changes.

Download your PDF

You now need to get your PDF from the Overleaf cloud to local storage. Very easy! Just press the little download icon above the right panel. I've circled it in red. You will get the usual file save dialog box. Give it a good name and put the file in a sensible place.

Display Your Presentation

The hard part is over! Now to reap the rewards. Open your presentation in whatever PDF software you generally use. For example, I can open it in Preview on my Mac. It looks splendid and I can navigate using the arrows on my keyboard.

And I can go into View -> Slideshow and I will get the view shown below of the presentation. I can use the arrow keys on my keyboard to go back and forth through the presentation. The embedded controls in the presentation itself are a little flaky in Preview but you don't really need to use them. I used this method in my constitutional law class last spring and the students were happy with it, despite the absence of some PowerPoint bells and whistles. (Indeed they very much liked the clean slides that AI had produced).

If you are fortunate enough to have a license for Adobe Acrobat, however, you can do even better. Open the PDF in Acrobat and then go into its "Full Screen Mode"via View->Full Screen Mode. You should see a nice full screen presentation window that will basically look like the one above from Preview. But ... the navigation buttons at the bottom right of the slide work perfectly.

Convert to PowerPoint

This is the annoying part. And it is often unnecessary. As indicated earlier, if you are willing to forego a few bells and whistles, you can get a perfectly serviceable classroom presentation just out of the PDF file. But, if you want to go further, this section of the blog entry is what you need to read.

It turns out that PDF (Adobe) and PowerPoint (Microsoft) do not play perfectly together. The main nightmare is font compatibility and spacing. Some of the complexity in the original LaTeX prefix I told AI to use (such as use of the Roboto font) has been designed to minimize this problem; residual issues nonetheless remain. For this stage of the process, I assume you have a PDF file that has exited the Overleaf cloud and is in local storage such as a hard drive or another cloud service such as Dropbox or even Google Drive. You then have many choices on how to convert to PowerPoint. I will outline two of them here. The first is to use a free online PDF converter. The advantage here is that it requires no set up. The disadvantage is that you lose privacy. I rather suspect that most of the free online services slurp up your content for training data.

Online using smallpdf

I have found smallpdf to work well without fuss. It seems to be free at least for a limited number of uses. Select the PDF file you want to upload.

It will take a moment for your file to upload. Then select PowerPoint as your desired export format.

The conversion takes less than a minute and, at the end of the process you get download options. Just press the download button and send the PowerPoint pptx file to a sensible location on your local storage.

And now we have a beautiful PowerPoint. I show the result below in slide sorter mode.

It's just as editable as a PowerPoint you created the old fashioned way. You can style it, edit it, add images (possibly themselves produced by AI), transitions, and whatever else you would do ordinarily.

Local conversion using Acrobat

If you don't want your PDF to become training data for some future AI or for your fascination with obscure provisions of the Constitution to become fodder for targeted advertisements, you can also do the conversion locally. The best software I have found for this is Adobe Acrobat. Sadly, it is not free but perhaps your university, like mine, has a site license and you can get it for free.

The process of using Acrobat to convert a PDF to a PowerPoint is simple. Here's my Acrobat home screen. Notice the "See all tools" link I've boxed in red?

Click on it and you should see the tool "Export a PDF." I've boxed it in purple for your convenience.

Open up that tool. You will then get a screen that looks like this:

If the Microsoft PowerPoint radio button isn't blue, click on it. Then just click on the Select a file button and select the PDF file that you got from Overleaf. You should then see your presentation appear like this:

And now it's time to say how much you've always admired Bill Gates and press the "Convert to PPTX" button. Give the output file a useful name. And ... voila.

A beautiful, editable PowerPoint. You can now do all the PowerPoint things. (Hopefully, you know the program better than Michael Scott.) Add transitions. Edit the text of the slides. Whatever you would ordinarily do. (Except I would not change themes as the slides already have a theme.)

Bonus Material

This method is more complicated than the one outlined in a prior blog post. So why do it? One answer is attractiveness. The other is flexibility.

Attractiveness

One simple thing you can do to change the appearance of your presentation is to tweak the "prefix" of your LaTeX code. The prefix is the stuff that comes before \begin{document}. The simplest way to change the appearance is to change the "theme" using the \usetheme directive. Common beamer themes built in to Overleaf include Bergen, Berkeley, Boadilla, Hannover, Madrid, and Metropolis

Here, for example, is the result of substituting \usetheme{Berkeley} instead of \usetheme{Madrid}.

Here's the metropolis theme (I just discovered the hard way that theme names are case sensitive!)

But you can go way beyond basic themes. People have spent decades designing open source methods of making beamer presentations look good. Overleaf provides a searchable library of templates. Here are some for presentations.

And, of course, AI can create themes for you. I asked AI to create a beamer presentation theme that conformed with the branding colors of the University of Houston. It did so. Here are the instructions. Here is the resulting "sty" file. Basically, you upload the sty file to the project directory and then just change one line of code. Instead of \usetheme{Madrid} you use \usetheme{UH}. Here's the result. Go Coogs!

Flexibility

The lovely thing about LaTeX, however, is that you are not limited to production of slides. You can build posters or articles and use time-tested LaTeX theme to structure the results. I will cover this in detail in another post, but the short version is you ask your AI to take whatever output you want and render it as a LaTeX article or poster or whatever. You then go through the same process of copy and pasting the AI-generated LaTeX code into into Overleaf, tweak and debug the LaTeX code, render it as a PDF and then further convert the PDF as you wish. Here's a query to generate a script for a lecture that tracks the PowerPoint.

Attached is a PDF of a slideshow on the June 2025 supreme court case of Mahmoud v. Taylor. I want you to write up a 2000 word script that captures what I am trying to say in the presentation. You should denote clearly which text goes with which slide. You can use the actual case opinion and the internet but your emphasis should be on what I saying in the presentation. Your audience is law students but you should not directly address them. The tone should be engaging but definitely not cutesy. Avoid cliches like "landmark" or "tapestry" or "watershed." Make sure to be objective and provide both liberal and conservative perspectives on the decision. Your output should be raw Latex code. Use this prefix. documentclass{article} 

 \usepackage[utf8]{inputenc} 
 \usepackage[T1]{fontenc} 
 \usepackage{fontspec} 
 \usepackage{unicode-math} 
 \setmainfont{Open Sans} 
 \setsansfont{Roboto} 
 \setmonofont{Roboto Mono} 
 \usetheme{UH} 
 \usepackage{amsmath,amsfonts,amssymb} 
 \usepackage{hyperref} 
 \usepackage{pdfcomment} %%% 
 \title{\textit{Mahmoud v. Taylor}} 
 \subtitle{A New Era for Free Exercise in Public Schools} 
 \author{Seth J. Chandler} 
 \institute{University of Houston Law Center} 
 \date{\today}

Within a few moments, AI has produced a LaTeX document that, as before, I copy and paste into a new Overleaf file (within the same project) that I call Mahmoud slide script. I look for obvious LaTeX errors, fine none, and press Recompile. Just as before. Here's an excerpt of the result in the right panel of Overleaf.

Again, I can save this as a PDF and then use conversion programs if I feel the need to turn it into Word.

You can even create a poster. Here's one that uses AI art. I will confess it took a couple of iterations to make it acceptable.

Debugging

The biggest impediment to using the methods outlined here are the occasional imperfections in the LaTeX code generated by AI and the challenges people untrained in LaTeX are likely to have in successfully debugging the resulting problems. As mentioned above, AI is your friend. Show AI the code and the error message and it is likely to tell you both the problem and how to fix it. Also, there are some errors that occur far more often than others from AI-generated LaTeX. Here's a table showing how to recognize and fix 10 common errors. If you know how to fix them, this method of producing PDF/PowerPoint via LaTeX and Overleaf works well.

Error Typical Error Message Diagnostic Hints Fix
Unescaped ampersand (&) ! Misplaced alignment tab character &. Log cites "Misplaced alignment tab character &."; line number shows the & outside any alignment env. Replace with \&.
Unescaped dollar sign ($) ! Missing $ inserted. or ! Double subscript. Look for "Missing $ inserted" or "Extra $" in the log; ensure each $…$ pair is balanced. Escape as \$; balance math delimiters.
Unescaped underscore (_) ! Missing $ inserted. "Missing $ inserted" at the underscore; occurs in text outside math mode. Escape as \_.
Unescaped percent sign (%) No immediate error (line is truncated) Content after % disappears; subsequent errors reference missing text. Escape as \%.
Mismatched braces ({/}) ! File ended while scanning use of … or ! Extra }, or forgotten \endgroup. "Runaway argument" or EOF while scanning; brace count mismatch. Ensure each { has a matching }.
Mismatched environment delimiters ! LaTeX Error: \begin{itemize} ended by \end{enumerate}. or Log shows the mismatched \begin{…} and \end{…} names. Close each environment with the same name.
! LaTeX Error: Environment figure undefined.
Undefined control sequence ! Undefined control sequence. Log pinpoints the unknown command (typo or missing backslash). Correct spelling or load the required package.
Missing package for env or macro ! LaTeX Error: Environment align undefined. or Log cites undefined environment/command; identify its package. Add \usepackage{amsmath}, \usepackage{graphicx}
! LaTeX Error: Command \includegraphics undefined. etc.
Alignment tab mismatch ! Extra alignment tab has been changed to \cr. or ! Misplaced \noalign. Column spec ({lll}) doesn’t match the number of &; each line in align needs the same number of & Use n–1 ampersands for n columns; match each row.
Case-sensitivity errors ! LaTeX Error: Environment Itemize undefined. or Log reports mis-cased name as undefined; LaTeX names are case-sensitive. Use exact lowercase names (e.g. \textbf).

Conclusion

Between this blog post and the prior one, you now have two methods for AI to generate editable first drafts of presentations. The prior blog post went through a method that had AI generate a hierarchical outline with indentation in the output signaling either a new slide or a lower level "bullet" in a slide. One then used a custom program to turn that indented text into an RTF file that PowerPoint could import. That method should work well for basic slides and, of course, once the contents are in PowerPoint, you can use all of its editing features to improve the presentation. This blog post traces an alternative workflow in which you harness the time-tested LaTeX language so ubiquitous in the sciences to create PDFs that can be used on a standalone basis to create useful in-class presentations or that can be converted to PowerPoint pptx files for further manipulation. This method immediately generates more attractive slides than the earlier method and has the fringe benefit of providing experience in using the extremely flexible LaTeX/Overleaf technologies to generate all sorts of products from AI.