[Tex/LaTex] Verbatim text can’t be shown correctly in pdf


I try to change the font of verbatim text as below

% Used by @verbatim ... @endverbatim

But I don't know why some characters cannot be shown in pdf

enter image description here

The example call is the verbatim text in the above figure. The variable name should be parameter_table_build_number, but pdf shows the underscore as an upper dot. I copied that dot and paste into notepad, it shows me the underscore. I searched the underscore in pdf, and it also indicates that dot is the underscore.

However, if I change the font to \footnotesize, it show me the correct character but the verbatim text will exceeds the paper's boundary.

enter image description here

Could anybody tell me how to fix this problem? Thanks a lot.

Best Answer

You can't use \verbatim ... \endverbatim inside a macro. A detailed explanation you can find here: TeX Frequently Asked Questions - Why doesn’t verbatim work within …?

You can use packages like listings, fancyvrb ...

Here an example with fancyvrb:




EDIT: Using listings: