On Fri, Aug 26, 2011 at 07:42, Alasdair McAndrew wrote:
Hello,
I'm writing up some student notes about Matlab, and I'm including examples of Matlab functions. I'd like all the functions to be typeset in typewriter font (which means using a "typing" environment), but I'd also like some colorization. For example, I want to display a function such as
function out = add(a,b) % % ADD(A,B) returns the sum of A and B % out = a+b;
in a frame, and with the three lines beginning with % all colored green. (If I can color reserved words like "function" that's even better.) What's the easiest way to achieve this?
You have three options: - use t-vim module (http://modules.contextgarden.net/vim) - manually apply commands for formatting - write a parser in lpeg (and plug it into existing highlighting functionality) Probably the easiest way is to use the vim module. (Vim does the syntax highlighting and TeX typesets the result. The layout is configurable.) Mojca