如何:在 PowerPoint 幻灯片上突出显示语法的 C# 源代码

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/825353/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-05 03:08:29  来源:igfitidea点击:

How to: C# source with syntax highlighting on PowerPoint slides

c#syntax-highlightingpowerpoint

提问by

I would like to show some C# source code in a PowerPoint presentation. But how can I copy the code including the syntax highlightingonto the slides? I could make screenshots, but that has some drawbacks (ugly, font size, unmaintainable). Do you have some ideas?

我想在 PowerPoint 演示文稿中展示一些 C# 源代码。但是如何将包括语法突出显示在内的代码复制到幻灯片上?我可以制作屏幕截图,但这有一些缺点(丑陋、字体大小、无法维护)。你有什么想法吗?

回答by sblom

  1. copy the code from Visual Studio to PowerPoint
  2. choose "keep original formatting" on the Paste Options icon
  1. 将代码从 Visual Studio 复制到 PowerPoint
  2. 在粘贴选项图标上选择“保持原始格式”

回答by Reed Copsey

You can use Windows Live Writer with the Insert Codeplugin to "write" the C# code and syntax highlight it. This should be copy and pastable directly into PowerPoint, since it's inlines all of the syntax highlighting using styling elements.

您可以使用带有插入代码插件的Windows Live Writer来“编写”C# 代码并在语法上突出显示它。这应该可以直接复制和粘贴到 PowerPoint 中,因为它使用样式元素内联了所有语法突出显示。

回答by Ishmael

"Paste Special" (Ctrl+Alt+V) will do it. This option is available in different places depending on your version of PowerPoint.

“选择性粘贴”(Ctrl+Alt+V)就可以了。根据您的 PowerPoint 版本,此选项在不同位置可用。

回答by Krogue2

If I copy the code from Visual Studio directly into PowerPoint, using Paste Special (and picking RTF), it only does someof the formatting.
Here is how I got it to do all the formatting.

如果我将代码从 Visual Studio 直接复制到 PowerPoint 中,使用选择性粘贴(并选择 RTF),它只会执行一些格式设置。
这是我如何让它完成所有格式化。

  1. Copy the code in Visual Studio. (Ctrl+C)
  2. Open a new Word document and do a paste. (Ctrl+V)
  3. Re-select the code in Word and copy it again. (Ctrl+A, Ctrl+C)
  4. In PowerPoint, do a Paste Special, as "HTML Format". (Ctrl+Alt+V)
  1. 在 Visual Studio 中复制代码。( Ctrl+ C)
  2. 打开一个新的 Word 文档并粘贴。( Ctrl+ V)
  3. 在 Word 中重新选择代码并再次复制。( Ctrl+ A, Ctrl+ C)
  4. 在 PowerPoint 中,执行选择性粘贴,作为“HTML 格式”。( Ctrl+ Alt+ V)

回答by StevenLee

  1. in PPT, click "Insert" -> "Object" -> "Create New" -> "Microsoft Word Document"
  2. Copy your code to the newly created object in PPT slides,
  3. You will see the formatting and highlight now.
  1. 在PPT中,点击“插入”->“对象”->“新建”->“Microsoft Word文档”
  2. 将您的代码复制到 PPT 幻灯片中新创建的对象中,
  3. 您现在将看到格式并突出显示。

回答by Roberto

In Notepad++6.9.2 or higher, right click the text and select Plugin Commandsand Copy Text with Syntax Highlighting.

Notepad++6.9.2 或更高版本中,右键单击文本并选择Plugin CommandsCopy Text with Syntax Highlighting

回答by Jaad Chacra

Copy and paste the code to WordPad, then copy from word pad to wherever you want and keep original formattingkeepOriginalFormatting

将代码复制并粘贴到写字板,然后从写字板复制到您想要的任何位置并保持原始格式保持原始格式