scriblib/figure: more configuration of style
This commit is contained in:
parent
ad6deb7366
commit
84f5301ac0
|
@ -15,21 +15,29 @@
|
|||
@defproc[(figure [tag string?] [caption content?]
|
||||
[p pre-flow?] ...
|
||||
[#:style style style? center-figure-style]
|
||||
[#:label-sep label-sep pre-content? ": "]
|
||||
[#:label-style label-style element-style? #f]
|
||||
[#:continue? continue? any/c #f])
|
||||
block?]
|
||||
@defproc[(figure* [tag string?] [caption content?]
|
||||
[p pre-flow?] ...
|
||||
[#:style style style? center-figure-style]
|
||||
[#:continue? continue? any/c #f])
|
||||
[#:label-sep label-sep pre-content? ": "]
|
||||
[#:label-style label-style element-style? #f]
|
||||
[#:continue? continue? any/c #f])
|
||||
block?]
|
||||
@defproc[(figure** [tag string?] [caption content?]
|
||||
[p pre-flow?] ...
|
||||
[#:style style style? center-figure-style]
|
||||
[#:label-sep label-sep pre-content? ": "]
|
||||
[#:label-style label-style element-style? #f]
|
||||
[#:continue? continue? any/c #f])
|
||||
block?]
|
||||
@defproc[(figure-here [tag string?] [caption content?]
|
||||
[pre-flow pre-flow?] ...
|
||||
[#:style style style? center-figure-style]
|
||||
[#:label-sep label-sep pre-content? ": "]
|
||||
[#:label-style label-style element-style? #f]
|
||||
[#:continue? continue? any/c #f])
|
||||
block?]
|
||||
)]{
|
||||
|
@ -52,8 +60,18 @@ By default, @racket[style] is set so that the content of the figure is
|
|||
centered. Use @racket[left-figure-style], @racket[center-figure-style],
|
||||
or @racket[right-figure-style] to specify the alignment.
|
||||
|
||||
The @racket[label-sep] and @racket[label-style] arguments adjust the
|
||||
way that the caption's label is shown. By default, the label is the
|
||||
word ``Figure'' followed by a space, the figure number, ``:'', and a
|
||||
space, but @racket[label-sep] can specify an alternative to the ``:''
|
||||
and ending space. The composed label is given the style specified by
|
||||
@racket[label-style].
|
||||
|
||||
If @racket[continue?] is a true value, then the figure counter is not
|
||||
incremented.}
|
||||
incremented.
|
||||
|
||||
@history[#:changed "1.24" @elem{Added the @racket[#:label-sep] and
|
||||
@racket[#:label-style] arguments.}]}
|
||||
|
||||
@deftogether[(
|
||||
@defthing[left-figure-style style?]
|
||||
|
|
|
@ -23,4 +23,4 @@
|
|||
|
||||
(define pkg-authors '(mflatt eli))
|
||||
|
||||
(define version "1.23")
|
||||
(define version "1.24")
|
||||
|
|
|
@ -66,30 +66,40 @@
|
|||
figure-style-extras))
|
||||
c))
|
||||
|
||||
(define default-label-sep ": ")
|
||||
|
||||
(define (figure tag caption
|
||||
#:style [style center-figure-style]
|
||||
#:label-sep [label-sep default-label-sep]
|
||||
#:label-style [label-style #f]
|
||||
#:continue? [continue? #f]
|
||||
. content)
|
||||
(figure-helper figure-style style tag caption content continue?))
|
||||
(figure-helper figure-style style label-sep label-style tag caption content continue?))
|
||||
|
||||
(define (figure-here tag caption
|
||||
#:style [style center-figure-style]
|
||||
#:style [style center-figure-style]
|
||||
#:label-sep [label-sep default-label-sep]
|
||||
#:label-style [label-style #f]
|
||||
#:continue? [continue? #f]
|
||||
. content)
|
||||
(figure-helper herefigure-style style tag caption content continue?))
|
||||
(figure-helper herefigure-style style label-sep label-style tag caption content continue?))
|
||||
|
||||
(define (figure* tag caption
|
||||
#:style [style center-figure-style]
|
||||
#:label-sep [label-sep default-label-sep]
|
||||
#:label-style [label-style #f]
|
||||
#:continue? [continue? #f]
|
||||
. content)
|
||||
(figure-helper figuremulti-style style tag caption content continue?))
|
||||
(figure-helper figuremulti-style style label-sep label-style tag caption content continue?))
|
||||
(define (figure** tag caption
|
||||
#:style [style center-figure-style]
|
||||
#:style [style center-figure-style]
|
||||
#:label-sep [label-sep default-label-sep]
|
||||
#:label-style [label-style #f]
|
||||
#:continue? [continue? #f]
|
||||
. content)
|
||||
(figure-helper figuremultiwide-style style tag caption content continue?))
|
||||
(figure-helper figuremultiwide-style style label-sep label-style tag caption content continue?))
|
||||
|
||||
(define (figure-helper figure-style content-style tag caption content continue?)
|
||||
(define (figure-helper figure-style content-style label-sep label-style tag caption content continue?)
|
||||
(make-nested-flow
|
||||
figure-style
|
||||
(list
|
||||
|
@ -101,15 +111,23 @@
|
|||
(list (make-element (if continue?
|
||||
legend-continued-style
|
||||
legend-style)
|
||||
(list (Figure-target tag #:continue? continue?) caption)))))))
|
||||
(list (Figure-target tag
|
||||
#:label-sep label-sep
|
||||
#:label-style label-style
|
||||
#:continue? continue?)
|
||||
caption)))))))
|
||||
|
||||
(define figures (new-counter "figure"
|
||||
#:target-wrap make-figure-target
|
||||
#:ref-wrap make-figure-ref))
|
||||
(define (Figure-target tag #:continue? [continue? #f])
|
||||
(define (Figure-target tag
|
||||
#:continue? [continue? #f]
|
||||
#:label-sep [label-sep ": "]
|
||||
#:label-style [label-style #f])
|
||||
(counter-target figures tag
|
||||
"Figure"
|
||||
(if continue? " (continued): " ": ")
|
||||
#:label-suffix (list (if continue? " (continued)" "") label-sep)
|
||||
#:label-style label-style
|
||||
#:target-style figure-target-style
|
||||
#:continue? continue?))
|
||||
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
|
||||
(define (counter-target counter tag label
|
||||
#:target-style [target-style #f]
|
||||
#:label-style [label-style #f]
|
||||
#:label-suffix [label-suffix '()]
|
||||
#:continue? [continue? #f]
|
||||
. content)
|
||||
(let ([content (decode-content content)])
|
||||
|
@ -34,10 +36,13 @@
|
|||
(make-delayed-element
|
||||
(lambda (renderer part ri)
|
||||
(let ([n (resolve-get part ri (tag->counter-tag counter tag "value"))])
|
||||
(let ([l (cons (format "~a" n) content)])
|
||||
(if label
|
||||
(list* label 'nbsp l)
|
||||
l))))
|
||||
(cons
|
||||
(make-element label-style
|
||||
(let ([l (cons (format "~a" n) (decode-content (list label-suffix)))])
|
||||
(if label
|
||||
(list* label 'nbsp l)
|
||||
l)))
|
||||
content)))
|
||||
(lambda () (if label
|
||||
(list* label 'nbsp "N" content)
|
||||
(cons "N" content)))
|
||||
|
|
Loading…
Reference in New Issue
Block a user