This question already has an answer here:
I have this urgent need to display two pieces of code side by side for comparison in my article. Displaying a code, I've couple of requirement
- Should indent properly
- Output should be syntax highlighted
- Should be as automatic as possible in handling long lines of code (that means, wrapping the lines if necessary)
- Code should be easily copied from output pdf
- Code can be arbitrarily long, i.e. spanning over many pages, so automatic handling of such thing would be preferred
I have explored two choices briefly, Verbatim and listing along with minipage. They sort of work alright! But only the output is absolutely hideous. What is a good setting for any of the two, which atleast would produce good looking output. For automation part, I can still write python scripts that would allow me to do that. If any of you know example of research articles that renders code in it beautifully- I'd appreciate if you share it with me. Keep in mind that I don't use Latex often.