diff --git a/collects/scriblib/figure.rkt b/collects/scriblib/figure.rkt index ab81d7d463..014034c95f 100644 --- a/collects/scriblib/figure.rkt +++ b/collects/scriblib/figure.rkt @@ -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")) diff --git a/collects/scriblib/scribblings/figure.scrbl b/collects/scriblib/scribblings/figure.scrbl index bea7b62af7..25e5c44335 100644 --- a/collects/scriblib/scribblings/figure.scrbl +++ b/collects/scriblib/scribblings/figure.scrbl @@ -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?]{