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

  • what application are you copying from? – John T Dec 21 '09 at 4:26
  • I use textmate, e-texteditor and eclipse the most. – Yousui Dec 21 '09 at 4:58

11 Answers 11


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

Click this icon and choose "Keep Source Formatting" :

enter image description here

| improve this answer | |
  • 2
    I don't see such a Paste Options icon. I don't see a button to give me these options. I'm using PowerPoint:mac 2011. I think I have seen it in Windows versions, however. – Acumenus Jul 19 '13 at 21:49
  • I tried different suggested methods and tools to copy from, but was actually missing that word/powerpoint was messing up the format by using "Destination Theme". Thanks! – Tim Büthe Jan 22 '14 at 11:23

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)

| improve this answer | |
  • 3
    With version 6.9.2 or higher it's working without NppExport plugin. Just make right-click on the selected text -> Plugin commands -> Copy Text with Syntax Highlighting. – Ivan Kochurkin Aug 7 '16 at 19:00
  • Current version of Notepad++ already comes with this plugin :) – fabriciorissetto Nov 27 '16 at 17:53

Pygments can format almost every format to rtf:

pygmentize -f rtf -o code.rtf code.py
| improve this answer | |
  • An online translator is available at pygments.org/demo – koppor Nov 25 '15 at 11:48
  • 5
    Same idea, straight to the OS X clipboard pygmentize -f rtf code.py | pbcopy. – Christian Long Mar 14 '16 at 14:28
  • Thanks for this. I got very favorable results with pygmentize -O style=paraiso-dark -f rtf -l aspx-cs Index.cshtml | pbcopy for syntax highlighting of a Razor view for use in a presentation. – Asbjørn Ulsberg Jun 20 '19 at 20:42
  • Adding to what @ChristianLong suggested, but for Linux: pygmentize -f rtf code.py | xclip -sel clip. Note that you will probably have to install xclip. – Matthew Cole Nov 19 '19 at 23:16

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.

| improve this answer | |
  • 8
    Image can be fuzzy when zoom in. – Yousui Dec 21 '09 at 4:58
  • Use the magnifier and then take a screenshot of that. – wbeard52 May 17 '15 at 0:57
  • 2
    Doing so can increase the size of the presentation file significantly. – Rufflewind Nov 10 '16 at 17:39
  • This also has the drawback that once screenshot, it is no longer possible to resize the column width. This becomes a problem if you try to fit a 80 column printout into a 2x1 horizontal slide layout, a 132 column source into a 1x2 vertical layout, for example. The pygmentize answer above doesn't suffer from this. – Matthew Cole Nov 19 '19 at 22:55
  1. Click on Insert → Object → OpenDocument Text
  2. Paste on opened panel
  3. Click outside.

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

| improve this answer | |
  • Doesn't work for power point 2010. I copied text from Notepad++ to Power point presentation but it looses colors and styling. – ART Jan 4 '16 at 5:11
  • 1
    If I use NPPExport pluging and use "copy RTF to clipboard" and then paste it works. – ART Jan 4 '16 at 5:13

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

| improve this answer | |
  • Pasting into ppt does not quite work here on Windows 10: The new lines are not pasted. – koppor Nov 24 '15 at 15:22

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

| improve this answer | |
  • Either way,  what does “Then do the formatting if necessary” mean? – Scott Apr 26 '17 at 19:10
  • It means if you want to do some changes of your own like aligning or indentation of code – selftaught91 Apr 26 '17 at 19:17
  • This was the only way that I could copy and paste code from IntelliJ (a special program used for writing code) – robert Nov 14 '19 at 4:15

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.

| improve this answer | |

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

| improve this answer | |
  • 1
    Works from Eclipse Juno to Word 2010, but not to Powerpoint 2010 - it loses the colours and converts some of them to bold text – DNA Sep 4 '13 at 17:21

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).

| improve this answer | |

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.

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.