In the document I'm working on, I'd like to put some typed code bits in frames, to get an appearance sort of like the code excerpts on the ConTeXtWiki. However, I've found myself needing to do a couple of rather ugly hacks to get that to work right, and I'm hoping for some suggestions on how to avoid that.

Here's what I have so far:

\def\typebufferframed[#1]{%
  \vskip\parskip
  \framed[background=color,
   backgroundcolor=gray,
   frame=on,
   strut=yes,
   offset=2mm,
   width=broad,
   framecolor=black,
   align=right]%
   {\vskip -11mm\typebuffer[#1]\vskip -5mm}}

\starttext
Plain text before the code.

\startbuffer[ex1]
This is an example.
\stopbuffer
\typebufferframed[ex1]

Plain text after the code.
\stoptext

The hacks that I'd like to get rid of:

It would be nice not to have to put the code in a buffer before typing it, since in general I only use these once. However, if I put \starttyping and \stoptyping inside a framed command (even if I don't encapsulate it in another function) it breaks, and putting \startframedtext in the before= command and \stopframedtext in the after= command of \setuptyping also doesn't work.

The spacing, when I do things the way that I'm doing them, is all wrong. The \vskip\parskip at the top is reasonably ok (although a bit annoying), but I'd really like to figure out how to get rid of the large negative \vskip's inside the frame.

Thanks!
- Brooks

_______________________________________________
ntg-context mailing list
[EMAIL PROTECTED]
http://www.ntg.nl/mailman/listinfo/ntg-context

Reply via email to