At 07:45 PM 6/12/2002 +0200, Kris Hermans wrote:
>Hi again!
>
>I'm writing a programming tutorial with ConTeXt. Therefore I have
>programlistings that I want to reference in my text. My idea is to labels
>together with verbatim text.
>
>For instance:
>
>\definelabel[programlisting][text=listing,
> location=inmargin,
> headstyle=small]
>
>And in my text I write:
>
>\listing\starttyping
>/* first.c : my first C program */
>#include <stdio.h>
>
>int main()
>{
> puts("Hello Everybody!");
> return 0;
>}
>\stoptyping
>
>This all works fine, but I expected the label ("listing 1.1") to appear in
>the margin AT THE SAME LINE as the first line of my programlisting (/*
>first.c ... */). However, the label is somewhat above the actual verbatim
>text.
This is because there is a \blank line preceding the typing, so better is:
\definelabel[programlisting][text=listing,
headstyle=small]
And in my text I write:
\margintitle{\programlisting}
\starttyping
/* first.c : my first C program */
#include <stdio.h>
int main()
{
puts("Hello Everybody!");
return 0;
}
\stoptyping
However, i would go for:
\definetyping
[listing]
[before=\margintitle{\programlisting}\blank,
after=\blank]
\startlisting
/* first.c : my first C program */
#include <stdio.h>
int main()
{
puts("Hello Everybody!");
return 0;
}
\stoplisting
Which is (1) more structured, (2) can be adapted without changing the
source, (3) saves keystrokes, and (4) looks nicer in the source code.
Hans
-------------------------------------------------------------------------
Hans Hagen | PRAGMA ADE | [EMAIL PROTECTED]
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: +31 (0)38 477 53 69 | fax: +31 (0)38 477 53 74 | www.pragma-ade.com
-------------------------------------------------------------------------
information: http://www.pragma-ade.com/roadmap.pdf
documentation: http://www.pragma-ade.com/showcase.pdf
-------------------------------------------------------------------------