如何在word中插入漂亮的代码

Stack Overflow上高赞回答

Here is the best way, for me, to add code inside word:

  • go to Insert tab, Text section, click object button (it’s on the right)
  • choose OpenDocument Text which will open a new embedded word document
  • copy and paste your code from Visual Studio / Eclipse inside this embedded word page
  • save and close
    The result looks very nice.

图示如下
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

Here are the advantages of this method:

  1. the code keeps its original layout and colors.
  2. the code is separated from the rest of the document, as if it was a picture or a chart.
  3. spelling errors won’t be highlighted in the code (this is cool !)
    And it takes only few seconds.

来自 StackOverflow