ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Matlab formatting?
@ 2011-08-26  5:42 Alasdair McAndrew
  2011-08-26  6:02 ` Mojca Miklavec
  0 siblings, 1 reply; 3+ messages in thread
From: Alasdair McAndrew @ 2011-08-26  5:42 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 696 bytes --]

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?

Thanks,
Alasdair

-- 
Blog: http://amca01.wordpress.com
Web:  http://bit.ly/Alasdair
Facebook: http://www.facebook.com/alasdair.mcandrew

[-- Attachment #1.2: Type: text/html, Size: 953 bytes --]

[-- Attachment #2: Type: text/plain, Size: 485 bytes --]

___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Matlab formatting?
  2011-08-26  5:42 Matlab formatting? Alasdair McAndrew
@ 2011-08-26  6:02 ` Mojca Miklavec
  2011-08-26  6:36   ` Alasdair McAndrew
  0 siblings, 1 reply; 3+ messages in thread
From: Mojca Miklavec @ 2011-08-26  6:02 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Matlab formatting?
  2011-08-26  6:02 ` Mojca Miklavec
@ 2011-08-26  6:36   ` Alasdair McAndrew
  0 siblings, 0 replies; 3+ messages in thread
From: Alasdair McAndrew @ 2011-08-26  6:36 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 1873 bytes --]

Thank you so much!  The vim module with Matlab formatting is just what I
wanted.

-Alasdair

On Fri, Aug 26, 2011 at 4:02 PM, Mojca Miklavec <
mojca.miklavec.lists@gmail.com> wrote:

> 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
>
> ___________________________________________________________________________________




-- 
Blog: http://amca01.wordpress.com
Web:  http://bit.ly/Alasdair
Facebook: http://www.facebook.com/alasdair.mcandrew

[-- Attachment #1.2: Type: text/html, Size: 2941 bytes --]

[-- Attachment #2: Type: text/plain, Size: 485 bytes --]

___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-08-26  6:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-26  5:42 Matlab formatting? Alasdair McAndrew
2011-08-26  6:02 ` Mojca Miklavec
2011-08-26  6:36   ` Alasdair McAndrew

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).