allow left-aligned figures
original commit: e01e72a7edcb050a657beb4c0dbf96afd6036039
This commit is contained in:
parent
8890f72c3a
commit
dd22d7eedb
|
@ -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 {
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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}}
|
||||
|
|
|
@ -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?]{
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user