Is it possible to embed programming source code to Powerpoint slide, and keep code highlighting/coloring?
11 Answers
After pasting, a small "Paste Options" icon appears below the pasted text.
Click this icon and choose "Keep Source Formatting" :
-
3I 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. Jul 19, 2013 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! Jan 22, 2014 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)
-
8With 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. Aug 7, 2016 at 19:00
-
2Current version of Notepad++ already comes with this plugin :) Nov 27, 2016 at 17:53
-
1
-
Direct copy to PowerPoint did not worked well, I paste the code to Word and copy it from word to PowerPoint Aug 28 at 4:45
Pygments can format almost every format to rtf:
pygmentize -f rtf -o code.rtf code.py
-
3
-
6Same idea, straight to the OS X clipboard
pygmentize -f rtf code.py | pbcopy
. Mar 14, 2016 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. Jun 20, 2019 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. Nov 19, 2019 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.
-
12
-
-
4Doing so can increase the size of the presentation file significantly. Nov 10, 2016 at 17:39
-
1This 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. Nov 19, 2019 at 22:55
- Click on Insert → Object → OpenDocument Text
- Paste on opened panel
- Click outside.
Note: Copying from Notepad++ will preserve colors and styling.
Copy the code and first paste that code into Microsoft word
Then do the formatting if necessary and then copy from word and paste back to powerpoint by right clicking and choosing use destination theme
-
Either way, what does “Then do the formatting if necessary” mean? Apr 26, 2017 at 19:10
-
It means if you want to do some changes of your own like aligning or indentation of code Apr 26, 2017 at 19:17
-
This was the only way that I could copy and paste code from IntelliJ (a special program used for writing code)– robertNov 14, 2019 at 4:15
Here's another approach:
- Find an online source code syntax highlighting service.
- Paste the code to highlight into the web site.
- Copy the highlighted version.
- Create a new Word document.
- Paste the code into Word (note the background colours may be lost).
- Copy the code from Word.
- Create a new text area in PowerPoint.
- Click the Home menu option.
- Open Paste on the ribbon.
- Select Keep source formatting.
- Optionally, change the text area background colour to taste.
Adjust the font using Inconsolata or other monospace font.
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
-
Pasting into ppt does not quite work here on Windows 10: The new lines are not pasted.– kopporNov 24, 2015 at 15:22
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.
Pasting from Eclipse should retain formatting if the app supports it. I know Word does... not sure about PPT.
-
1Works from Eclipse Juno to Word 2010, but not to Powerpoint 2010 - it loses the colours and converts some of them to bold text– DNASep 4, 2013 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).