[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Counter in Markup
From: |
Adam Good |
Subject: |
Counter in Markup |
Date: |
Thu, 24 Feb 2011 19:39:58 +0100 |
Hi All,
I'm wanting to use this great counter markup code:
"Implementing a counter in markup text"
http://lsr.dsi.unimi.it/LSR/Snippet?id=543
though I would like to use it with \mark for example:
\mark \markup {\counter #"mycounter"}
But it gives results I don't expect and I'm having difficulty
understanding why. Can anyone help me?
Thanks!
Here's a snippet...
%%%%
#(define counter-alist '())
#(define-markup-command (counter layout props name) (string?)
"Increases and prints out the value of the given counter named @var{name}.
If the counter does not yet exist, it is initialized with 1."
(let* ((oldval (assoc-ref counter-alist name))
(newval (if (number? oldval) (+ oldval 1) 1)))
(set! counter-alist (assoc-set! counter-alist name newval))
(interpret-markup layout props
(markup (number->string newval)))))
\relative c' {
\mark \markup {\counter #"mycounter" "(why not 1?)"}
c2^\markup {\counter #"mycounter" }
d
e^\markup {\counter #"mycounter" }
f
g^\markup {\counter #"mycounter" }
a
}
- Counter in Markup,
Adam Good <=