ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Mojca Miklavec <mojca.miklavec.lists@gmail.com>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: Matlab formatting?
Date: Fri, 26 Aug 2011 08:02:56 +0200	[thread overview]
Message-ID: <CALBOmsYEBXZkFE1QxOw+AetXj3qOR_5r7Bv+bYBkUqkeL1kjhw@mail.gmail.com> (raw)
In-Reply-To: <CAPGiC76KYH8qPPF+M7kCeTXM99NA1M=XyGHkk=wkUcofbt2KJw@mail.gmail.com>

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
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

  reply	other threads:[~2011-08-26  6:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-26  5:42 Alasdair McAndrew
2011-08-26  6:02 ` Mojca Miklavec [this message]
2011-08-26  6:36   ` Alasdair McAndrew

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CALBOmsYEBXZkFE1QxOw+AetXj3qOR_5r7Bv+bYBkUqkeL1kjhw@mail.gmail.com \
    --to=mojca.miklavec.lists@gmail.com \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).