From: Hans Hagen <pragma@wxs.nl>
Cc: "ConTeXt Mailing List" <ntg-context@ntg.nl>
Subject: Re: numbered programlistings
Date: Thu, 13 Jun 2002 09:29:21 +0200 [thread overview]
Message-ID: <5.1.0.14.1.20020613092718.032f3e88@server-1> (raw)
In-Reply-To: <NPEAKMHEICNGLIJBLOONEECPCBAA.KrisHermans@advalvas.be>
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 | pragma@wxs.nl
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
-------------------------------------------------------------------------
prev parent reply other threads:[~2002-06-13 7:29 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-06-12 17:45 Kris Hermans
2002-06-12 20:00 ` Berend de Boer
2002-06-13 7:29 ` Hans Hagen [this message]
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=5.1.0.14.1.20020613092718.032f3e88@server-1 \
--to=pragma@wxs.nl \
--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).