How can I embed programming source code in Powerpoint slide and keep code highlighting?

Is it possible to embed programming source code to Powerpoint slide, and keep code highlighting/coloring?


Solution 1:

After pasting, a small "Paste Options" icon appears below the pasted text.

Click this icon and choose "Keep Source Formatting" :

enter image description here

Solution 2:

Use Notepad++ with add-on NppExport.

  • Select the source code

  • Use Copy RTF to clipboard of NppExport

  • Paste into empty PPT slide (do not select any textfiled)

Solution 3:

Pygments can format almost every format to rtf:

pygmentize -f rtf -o code.rtf code.py

Solution 4:

If the source code does not need to be copied and pasted out of the presentation, a quick and dirty solution could be to simply take screenshots of the source code.

Solution 5:

  1. Click on Insert → Object → OpenDocument Text
  2. Paste on opened panel
  3. Click outside.

Note: Copying from Notepad++ will preserve colors and styling.