xcode 如何使用语法高亮将 Objective C 代码放入 Word (Office)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4943730/
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
How to put Objective C code into Word (Office) with syntax highlighting
提问by brush51
I am writing documentation about an app and want to explain the code. I want to copy parts of the Objective C code from Xcode to Microsoft Word. I don't know how to put the code with syntax highlighting (and maybe line numbers, too ?!) into Word.
我正在编写有关应用程序的文档并想解释代码。我想将部分 Objective C 代码从 Xcode 复制到 Microsoft Word。我不知道如何将带有语法突出显示(也可能是行号?!)的代码放入 Word。
Does anybody know a usable solution for this little problem?
有人知道这个小问题的可用解决方案吗?
回答by Michel Guillet
Copy and paste works !
复制和粘贴作品!
Nevertheless, make sure the option "Copy colors and fonts"
in Preferences>Fonts & Colors
is checked !
尽管如此,确保选项"Copy colors and fonts"
中Preferences>Fonts & Colors
被选中!
回答by SteveG
If you need this in Pages you can paste into textedit then copy/paste from textedit into pages. I have yet to find a way to paste directly into pages and preserve the text color etc
如果您在 Pages 中需要这个,您可以粘贴到 textedit 中,然后从 textedit 复制/粘贴到页面中。我还没有找到一种直接粘贴到页面中并保留文本颜色等的方法
回答by Paul R
If you copy from Xcode and paste into Word you get syntax highlighting etc as expected. You just need to reduce the font size to make it more readable and avoid wrapping etc. It would probably be a good idea to define a suitable Style in Word, e.g. "Code" which would have the required font size etc for pasted code.
如果您从 Xcode 复制并粘贴到 Word 中,您会按预期获得语法突出显示等。您只需要减小字体大小以使其更具可读性并避免换行等。在 Word 中定义合适的样式可能是个好主意,例如“代码”,它具有粘贴代码所需的字体大小等。
回答by wcrane
It supports these by default in Xcode 4. And what you need to do is to choose "Use Orignal Format" in Word or Power Point.
它在 Xcode 4 中默认支持这些。您需要做的是在 Word 或 Power Point 中选择“使用原始格式”。
回答by Bjinse
If you need this in Pages, then a workaround is to copy in Xcode, paste in Word, copy again and then paste in Pages (That is if you have MS Word available).
如果您在 Pages 中需要这个,那么解决方法是在 Xcode 中复制,粘贴到 Word 中,再次复制然后粘贴到 Pages 中(也就是说,如果您有可用的 MS Word)。