Is it possible to embed programming source code to Powerpoint slide, and keep code highlighting/coloring?
211 Answers
After pasting, a small "Paste Options" icon appears below the pasted text.
Click this icon and choose "Keep Source Formatting" :
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)
Pygments can format almost every format to rtf:
pygmentize -f rtf -o code.rtf code.py 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.
4- Click on Insert → Object → OpenDocument Text
- Paste on opened panel
- Click outside.
Note: Copying from Notepad++ will preserve colors and styling.
2Here'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,
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
1Copy 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
3Pasting from Eclipse should retain formatting if the app supports it. I know Word does... not sure about PPT.
1I'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).
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.