A
A
Artem Sorokin2013-06-09 19:54:41
Programming
Artem Sorokin, 2013-06-09 19:54:41

How to format program code (C++) in Microsoft Word?

There is a C ++ program code that needs to be inserted into a report on work in Word 2013.
But if you directly insert it, you get completely unreadable rubbish.
I want to arrange it the way the code looks in the compiler - with line numbers, correct formatting and syntax highlighting.
I did not find any built-in tools for this. Tell me how can this be done?

Answer the question

In order to leave comments, you need to log in

6 answer(s)
P
phil_tsarik, 2013-06-09
@artyums

I did not find any built-in tools for this.

How so? Create your own style, adjust the font, indents, tabs, and so on. Insert text and apply your style to it. The highlight will remain if the style does not override the font color.
With line numbers, it will be more difficult - you will need to set up your own numbering style, and specify in the paragraph style created above to use this numbering.
For example, you can achieve the following results
Download doc: https://www.dropbox.com/s/8fvq11sw5k0tvky/example....

E
Egor Tolstoy, 2013-06-09
@YourDestiny

tohtml.com/ - An online code editor with syntax highlighting for a bunch of different languages. Received copy-paste in Word.

A
Alexey, 2013-06-09
@Renzo

From Microsoft Visual Studio, Qt Creator, Eclipse (yes, almost from all IDEs), the code is copied formatted, highlighted, etc.

N
Nikita Permin, 2013-06-09
@NekitoSP

I probably won’t help you with line numbers, but the highlight is perfectly copied from Qt Creator.

A
affinity, 2013-06-10
@affinity

For these purposes, I use Notepad ++ - it has the function of copying RTF to the buffer, the
only thing that there will be no line numbers, it seems

@
@ntkt, 2013-06-09
_

I always insert preformatted text into a table.
The table consists of one large cell if a self-sufficient piece of code or a log fragment is inserted, and several cells if headers or comments are needed.
And as for the syntax highlighting in the copied code, the colleagues above have already said everything.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question