diff --git a/collects/scriblib/figure.css b/collects/scriblib/figure.css index 5978f66b..1b28242b 100644 --- a/collects/scriblib/figure.css +++ b/collects/scriblib/figure.css @@ -1,9 +1,20 @@ +.Centertext { + text-align: center; +} + .Centerfigure, .CenterfigureMulti, .centerfigureMultiWide, .Herefigure { + text-align: center; +} + +.Leftfigure, .LeftfigureMulti, .leftfigureMultiWide { + text-align: left; +} + +.Figure { margin: 1em 0 1em 0; width: 100%; border: 1px solid #1818FF; - text-align: center; } .CenterfigureMultiWide { diff --git a/collects/scriblib/figure.rkt b/collects/scriblib/figure.rkt index 589bf75f..a30dd1c4 100644 --- a/collects/scriblib/figure.rkt +++ b/collects/scriblib/figure.rkt @@ -14,7 +14,10 @@ figure-here Figure-target Figure-ref - figure-ref) + figure-ref + (rename-out [leftfigure-style left] + [leftfiguremulti-style leftfiguremulti] + [leftfiguremultiwide-style leftfiguremultiwide])) (define figure-style-extras (let ([abs (lambda (s) @@ -23,32 +26,43 @@ (list (make-css-addition (abs "figure.css")) (make-tex-addition (abs "figure.tex"))))) -(define centerfigure-style (make-style "Centerfigure" figure-style-extras)) (define herefigure-style (make-style "Herefigure" figure-style-extras)) (define figureinside-style (make-style "FigureInside" figure-style-extras)) (define legend-style (make-style "Legend" figure-style-extras)) + +(define centertext-style (make-style "Centertext" figure-style-extras)) +(define figure-style (make-style "Figure" figure-style-extras)) + +(define centerfigure-style (make-style "Centerfigure" figure-style-extras)) (define centerfiguremulti-style (make-style "CenterfigureMulti" figure-style-extras)) (define centerfiguremultiwide-style (make-style "CenterfigureMultiWide" figure-style-extras)) -(define (figure tag caption . content) - (apply figure-helper centerfigure-style tag caption content)) +(define leftfigure-style (make-style "Leftfigure" figure-style-extras)) +(define leftfiguremulti-style (make-style "LeftfigureMulti" figure-style-extras)) +(define leftfiguremultiwide-style (make-style "LeftfigureMultiWide" figure-style-extras)) + +(define (figure tag caption #:style [style centerfigure-style] . content) + (apply figure-helper style tag caption content)) (define (figure-here tag caption . content) (apply figure-helper herefigure-style tag caption content)) (define (figure-helper style tag caption . content) - (make-nested-flow - style + (make-nested-flow + figure-style (list (make-nested-flow - figureinside-style - (append - (decode-flow content) - (list - (make-paragraph - plain - (list - (make-element legend-style - (list (Figure-target tag) ": " - caption)))))))))) + style + (list + (make-nested-flow + figureinside-style + (append + (decode-flow content) + (list))))) + (make-paragraph + centertext-style + (list + (make-element legend-style + (list (Figure-target tag) ": " + caption))))))) (define (*figure style tag caption content) (make-nested-flow @@ -66,10 +80,10 @@ (list (Figure-target tag) ": " caption)))))))))) -(define (figure* tag caption . content) - (*figure centerfiguremulti-style tag caption content)) -(define (figure** tag caption . content) - (*figure centerfiguremultiwide-style tag caption content)) +(define (figure* tag caption #:style [style centerfiguremulti-style] . content) + (*figure style tag caption content)) +(define (figure** tag caption #:style [style centerfiguremultiwide-style] . content) + (*figure style tag caption content)) (define figures (new-counter "figure")) (define (Figure-target tag) diff --git a/collects/scriblib/figure.tex b/collects/scriblib/figure.tex index 737ca3e7..17feceaa 100644 --- a/collects/scriblib/figure.tex +++ b/collects/scriblib/figure.tex @@ -14,3 +14,7 @@ \newenvironment{Centerfigure}{\begin{figure}[t!p]\centering}{\end{figure}} \newenvironment{Herefigure}{\begin{figure}[ht!p]\centering}{\end{figure}} \newenvironment{FigureInside}{\begin{list}{}{\leftmargin=0pt\topsep=0pt\parsep=\FigOrigskip\partopsep=0pt}\item}{\end{list}} + +\newenvironment{LeftfigureMulti}{\begin{figure*}[t!p]}{\end{figure*}} +\newenvironment{LeftfigureMultiWide}{\begin{leftfigureMulti}}{\end{leftfigureMulti}} +\newenvironment{Leftfigure}{\begin{figure}[t!p]}{\end{figure}} diff --git a/collects/scriblib/scribblings/figure.scrbl b/collects/scriblib/scribblings/figure.scrbl index 9f8d936e..bea7b62a 100644 --- a/collects/scriblib/scribblings/figure.scrbl +++ b/collects/scriblib/scribblings/figure.scrbl @@ -10,9 +10,9 @@ @defmodule[scriblib/figure] @deftogether[( -@defproc[(figure [tag string?] [caption content?] [pre-flow pre-flow?] ...) block?] -@defproc[(figure* [tag string?] [caption content?] [pre-flow pre-flow?] ...) block?] -@defproc[(figure** [tag string?] [caption content?] [pre-flow pre-flow?] ...) +@defproc[(figure [tag string?] [caption content?] [#:style style style?] [p pre-flow?] ...) block?] +@defproc[(figure* [tag string?] [caption content?] [#:style style style?] [p pre-flow?] ...) block?] +@defproc[(figure** [tag string?] [caption content?] [#:style style style?] [p pre-flow?] ...) block?] @defproc[(figure-here [tag string?] [caption content?] [pre-flow pre-flow?] ...) block?] )]{ @@ -30,8 +30,16 @@ generate a figure that spans columns. For Latex output, @racket[figure-here] generates a figure to be included at the position in the output text where the @racket[figure-here] occurs in the source text. For HTML output, all @racket[figure] variants -place the figure where the use appears in the source text.} +place the figure where the use appears in the source text. +By default @racket[style] is set so that the content of the figure is centered. +For a figure that demands left-aligned text, use @racket[left]. + +} + +@defthing[left style?]{ +Implements a style for left-aligned figures. +} @defproc[(figure-ref [tag string?]) element?]{