I know there is a very good package for listing code (listing package) but codes are ugly.
I know there are some good package for algorithms (algorithmics, algorithm2e, etc). But I want to write runnable code not only printable one.
So, is there any way to include programming code into a tex article that looks as nice as algorithms? Or, is there any (automatic) way to convert a programming code into a latex algorithm?
Some ideas that I have explored but so far they were not good enough.
Converting Python to latex.
I found a Python library to convert Python expressions into latex based on this question on stackoverflow: https://stackoverflow.com/questions/3867028/converting-a-python-numeric-expression-to-latex
Writing in literate programming style (noweb)
Problem: CWEB output is nice but noweb output is just code listing. CWEB unfortunately was designed for C language.
Edit: Well, see the example below (I got from http://www.literateprogramming.com/cweb.pdf)
Why is this so nice? For example, the operator "!=" was converted to latex \neq. Or the "!" boolean operator was converted to "\neg". And so on...
Now, another example with algorithmicx package.
Can we achieve that with listing?
Disclaimer
Since I copied this snippet from CWEB Manual, I have to put this copyright note here...
The printed form of this manual is copyright 1994 by Addison-Wesley Publishing Company, Inc. All rights reserved. The electronic form is copyright 1987, 1990, 1993, 2000 by Silvio Levy and Donald E. Knuth. Permission is granted to make and distribute verbatim copies of the electronic form of this document provided that the electronic copyright notice and this permission notice are preserved on all copies. Permission is granted to copy and distribute modified versions of the electronic form of this document under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one.


1vsIvslcan't be assumed to be inferrable from context, limiting your fonts and aesthetic formatting) – Chris H Jan 11 '17 at 16:24literatetools. You might also see Listings, Literate Programming, and Beautiful Typography – Chris H Jan 11 '17 at 16:58