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 {
|
.Centerfigure, .CenterfigureMulti, .centerfigureMultiWide, .Herefigure {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.Leftfigure, .LeftfigureMulti, .leftfigureMultiWide {
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.Figure {
|
||||||
margin: 1em 0 1em 0;
|
margin: 1em 0 1em 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
border: 1px solid #1818FF;
|
border: 1px solid #1818FF;
|
||||||
text-align: center;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.CenterfigureMultiWide {
|
.CenterfigureMultiWide {
|
||||||
|
|
|
@ -14,7 +14,10 @@
|
||||||
figure-here
|
figure-here
|
||||||
Figure-target
|
Figure-target
|
||||||
Figure-ref
|
Figure-ref
|
||||||
figure-ref)
|
figure-ref
|
||||||
|
(rename-out [leftfigure-style left]
|
||||||
|
[leftfiguremulti-style leftfiguremulti]
|
||||||
|
[leftfiguremultiwide-style leftfiguremultiwide]))
|
||||||
|
|
||||||
(define figure-style-extras
|
(define figure-style-extras
|
||||||
(let ([abs (lambda (s)
|
(let ([abs (lambda (s)
|
||||||
|
@ -23,32 +26,43 @@
|
||||||
(list (make-css-addition (abs "figure.css"))
|
(list (make-css-addition (abs "figure.css"))
|
||||||
(make-tex-addition (abs "figure.tex")))))
|
(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 herefigure-style (make-style "Herefigure" figure-style-extras))
|
||||||
(define figureinside-style (make-style "FigureInside" figure-style-extras))
|
(define figureinside-style (make-style "FigureInside" figure-style-extras))
|
||||||
(define legend-style (make-style "Legend" 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 centerfiguremulti-style (make-style "CenterfigureMulti" figure-style-extras))
|
||||||
(define centerfiguremultiwide-style (make-style "CenterfigureMultiWide" figure-style-extras))
|
(define centerfiguremultiwide-style (make-style "CenterfigureMultiWide" figure-style-extras))
|
||||||
|
|
||||||
(define (figure tag caption . content)
|
(define leftfigure-style (make-style "Leftfigure" figure-style-extras))
|
||||||
(apply figure-helper centerfigure-style tag caption content))
|
(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)
|
(define (figure-here tag caption . content)
|
||||||
(apply figure-helper herefigure-style tag caption content))
|
(apply figure-helper herefigure-style tag caption content))
|
||||||
(define (figure-helper style tag caption . content)
|
(define (figure-helper style tag caption . content)
|
||||||
(make-nested-flow
|
(make-nested-flow
|
||||||
style
|
figure-style
|
||||||
(list
|
(list
|
||||||
(make-nested-flow
|
(make-nested-flow
|
||||||
figureinside-style
|
style
|
||||||
(append
|
(list
|
||||||
(decode-flow content)
|
(make-nested-flow
|
||||||
(list
|
figureinside-style
|
||||||
(make-paragraph
|
(append
|
||||||
plain
|
(decode-flow content)
|
||||||
(list
|
(list)))))
|
||||||
(make-element legend-style
|
(make-paragraph
|
||||||
(list (Figure-target tag) ": "
|
centertext-style
|
||||||
caption))))))))))
|
(list
|
||||||
|
(make-element legend-style
|
||||||
|
(list (Figure-target tag) ": "
|
||||||
|
caption)))))))
|
||||||
|
|
||||||
(define (*figure style tag caption content)
|
(define (*figure style tag caption content)
|
||||||
(make-nested-flow
|
(make-nested-flow
|
||||||
|
@ -66,10 +80,10 @@
|
||||||
(list (Figure-target tag) ": "
|
(list (Figure-target tag) ": "
|
||||||
caption))))))))))
|
caption))))))))))
|
||||||
|
|
||||||
(define (figure* tag caption . content)
|
(define (figure* tag caption #:style [style centerfiguremulti-style] . content)
|
||||||
(*figure centerfiguremulti-style tag caption content))
|
(*figure style tag caption content))
|
||||||
(define (figure** tag caption . content)
|
(define (figure** tag caption #:style [style centerfiguremultiwide-style] . content)
|
||||||
(*figure centerfiguremultiwide-style tag caption content))
|
(*figure style tag caption content))
|
||||||
|
|
||||||
(define figures (new-counter "figure"))
|
(define figures (new-counter "figure"))
|
||||||
(define (Figure-target tag)
|
(define (Figure-target tag)
|
||||||
|
|
|
@ -14,3 +14,7 @@
|
||||||
\newenvironment{Centerfigure}{\begin{figure}[t!p]\centering}{\end{figure}}
|
\newenvironment{Centerfigure}{\begin{figure}[t!p]\centering}{\end{figure}}
|
||||||
\newenvironment{Herefigure}{\begin{figure}[ht!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{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]
|
@defmodule[scriblib/figure]
|
||||||
|
|
||||||
@deftogether[(
|
@deftogether[(
|
||||||
@defproc[(figure [tag string?] [caption content?] [pre-flow pre-flow?] ...) block?]
|
@defproc[(figure [tag string?] [caption content?] [#:style style style?] [p pre-flow?] ...) block?]
|
||||||
@defproc[(figure* [tag string?] [caption content?] [pre-flow pre-flow?] ...) block?]
|
@defproc[(figure* [tag string?] [caption content?] [#:style style style?] [p 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?]
|
block?]
|
||||||
@defproc[(figure-here [tag string?] [caption content?] [pre-flow 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
|
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
|
the position in the output text where the @racket[figure-here] occurs
|
||||||
in the source text. For HTML output, all @racket[figure] variants
|
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?]{
|
@defproc[(figure-ref [tag string?]) element?]{
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user