scriblib/figure: support references to multiple figures at once

original commit: 4a6bfacc27f81bb757001694dd5250eedbd728fd
This commit is contained in:
Matthew Flatt 2012-07-31 06:58:19 -06:00
parent 8f8f8315c5
commit e285bfb53b
2 changed files with 27 additions and 8 deletions

View File

@ -75,7 +75,26 @@
(define figures (new-counter "figure"))
(define (Figure-target tag)
(counter-target figures tag "Figure"))
(define (Figure-ref tag)
(make-element #f (list (counter-ref figures tag "Figure"))))
(define (figure-ref tag)
(make-element #f (list (counter-ref figures tag "figure"))))
(define (ref-proc initial)
(case-lambda
[(tag)
(make-element #f (list (counter-ref figures tag (string-append initial "igure"))))]
[(tag1 tag2)
(make-element #f (list (counter-ref figures tag1 (string-append initial "igures"))
" and "
(counter-ref figures tag2 #f)))]
[(tag . tags)
(make-element #f (cons (counter-ref figures tag (string-append initial "igures"))
(let loop ([tags tags])
(cond
[(null? (cdr tags))
(list ", and "
(counter-ref figures (car tags) #f))]
[else
(list* ", "
(counter-ref figures (car tags) #f)
(loop (cdr tags)))]))))]))
(define Figure-ref (ref-proc "F"))
(define figure-ref (ref-proc "f"))

View File

@ -41,14 +41,14 @@ For a figure that demands left-aligned text, use @racket[left].
Implements a style for left-aligned figures.
}
@defproc[(figure-ref [tag string?]) element?]{
@defproc[(figure-ref [tag string?] ...+) element?]{
Generates a reference to a figure, using a lowercase word ``figure''.}
Generates a reference to one or more figures, using a lowercase word ``figure''.}
@defproc[(Figure-ref [tag string?]) element?]{
@defproc[(Figure-ref [tag string?] ...+) element?]{
Generates a reference to a figure, capitalizing the word ``Figure''.}
Generates a reference to one or more figures, capitalizing the word ``Figure''.}
@defproc[(Figure-target [tag string?]) element?]{