PowerPoint: Inserting Source Code with Syntax Highlighting

Jun 10, 2021 08:46 · 139 words · 1 minute read

When giving talks, I often want to show some small code samples on my slides. Of course, it should look nice and have syntax highlighting. This is not an easy feat. There are several options for showing code on your slides:

  • You can use a presentation software that can manage source code highlighting out of the box, e.g. Reveal.js or the LaTeX beamer package
  • You can convert the code to an image via Carbon or Codeimg.

But, if you, like me, want to continue using PowerPoint (the whole company is using PowerPoint & we often combine slides from different slide decks), there is another very easy option available: Just put your code into VS Code, enable syntax highlighting, and then copy-paste the code into PowerPoint. The formatting - including syntax highlighting - will stay intact magically. Just awesome 😍