Add background color to code block in word

background

I often encounter writing word documents at work, such as recording the deployment steps of a certain project. At this time, a clear and concise operation document can achieve twice the result with half the effort, such as the document used in the deployment process command or code to increase the background color, it will look more clear

Implementation

There are two ways to achieve this effect

Method 1
Copy and paste the written code into word in the code editor, such as pycharm, vs code, etc.

Method 2
This method is implemented inside Word, and the steps are as follows:

1- As shown in the picture below, I enter a few lines of code in word, and the background color is normal white at this time
insert image description here

2- The content in the above picture is not highlighted, at this time, select the code line or code segment that needs to be highlighted, select [Page Layout] - [Page Border], select [Shading] in the pop-up window, and click the following figure operate

insert image description here

3- After confirming, the effect is as follows, and it looks more layered and clear at this time.

insert image description here

Precautions

In the above step 2, in addition to selecting [Paragraph], you can also select [Text]. If you select [Text], you will only add a background color to the selected text, as shown in the figure below, depending on your own situation.

insert image description here

Guess you like

Origin blog.csdn.net/qq_33999977/article/details/126759824