156

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

anderas
  • 105
Yousui
  • 1,917

11 Answers11

70

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

Click this icon and choose "Keep Source Formatting" :

enter image description here

Gareth
  • 19,080
harrymc
  • 498,455
61

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)

Jawa
  • 3,679
voter
  • 711
  • 5
  • 3
33

Pygments can format almost every format to rtf:

pygmentize -f rtf -o code.rtf code.py
schlamar
  • 481
  • 1
  • 5
  • 9
6

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.

Emory Bell
  • 1,401
3

Here's another approach:

  1. Find an online source code syntax highlighting service.
  2. Paste the code to highlight into the web site.
  3. Copy the highlighted version.
  4. Create a new Word document.
  5. Paste the code into Word (note the background colours may be lost).
  6. Copy the code from Word.
  7. Create a new text area in PowerPoint.
  8. Click the Home menu option.
  9. Open Paste on the ribbon.
  10. Select Keep source formatting.
  11. Optionally, change the text area background colour to taste.

Adjust the font using Inconsolata or other monospace font.

Dave Jarvis
  • 3,427
3
  1. Click on Insert → Object → OpenDocument Text
  2. Paste on opened panel
  3. Click outside.

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

random
  • 15,201
2

Copy the code and first paste that code into Microsoft word

enter image description here

Then do the formatting if necessary and then copy from word and paste back to powerpoint by right clicking and choosing use destination theme

enter image description here

1

Using Notepad++ and Npp Export works great, but your text will end up with a white background.

To remove it, paste first the text in word with the "preserve source formatting" option. Then, select the text and in Home > Font, remove the background with the Text Highlight Color option.

Then, copy again the text from word, and paste it in powerpoint with the "preserve source formatting" option.

John
  • 21
1

Online syntax highlighter like TextMate seems good as well, http://markup.su/highlighter/

But after pasting into PowerPoint presentation new lines and line spacing is lost, so we can take a screen shot of the preview and paste it in our PowerPoint presentation

0

I've had no success pasting into Powerpoint 2010 on Windows.

However, pasting from Eclipse into Word 2010 works.

You can then save this formatted text as an RTF file, then embed the RTF into a Powerpoint 2010 slide using Insert Object (and optionally select 'link' so you can edit and update the text in Word).

DNA
  • 196
0

Pasting from Eclipse should retain formatting if the app supports it. I know Word does... not sure about PPT.

Chris Nava
  • 7,258