Typos and rephrasings suggested by O. Andreescu. Thanks!

This commit is contained in:
Georges Dupéron 2016-08-13 22:29:03 +02:00
parent b442197d53
commit 3516076e63

View File

@ -43,20 +43,22 @@ in Scribble documents.
@scribblecode|{@title[#:style (with-html5 manual-doc-style)]{…}}|) @scribblecode|{@title[#:style (with-html5 manual-doc-style)]{…}}|)
The following functions help with typesetting mathematical The following functions help with typesetting mathematical
equations. The main functions are @racket[$] for inline mode equations. The main functions are @racket[$] for
math, @racket[$$] for display mode math. The functions @tech{inline mode} math and @racket[$$] for @tech{display
@racket[use-katex] and @racket[use-mathjax] change the mode} math, respectively. The functions @racket[use-katex]
rendering engine used, the default being @racket[katex]. To and @racket[use-mathjax] change the rendering engine used,
use @racket[katex], it is necessary to use the default being @racket[katex]. To use @racket[katex], it
@title-html5-code or a similar configuration, see the is necessary to use
documentation for @racket[with-html5] for more details. @title-html5-code or a similar configuration; for more
details see the documentation of @racket[with-html5].
@defproc[($ [str string?] ...) element?]{ @defproc[($ [str string?] ...) element?]{
Renders the given strings as inline math, using MathJax or Renders the given strings as @deftech{inline mode} math.
KaTeX for the HTML output, depending on the current Inline mode math is typeset as part of the surrounding
configuration. For the LaTeX output, the code is simply text. Either MathJax or KaTeX is used for the HTML output,
passed as-is. For example, when using MathJax, depending on the current configuration. For the LaTeX
@racket[($ "x^2")] renders as output, the code is simply passed as-is. For example, when
using MathJax, @racket[($ "x^2")] renders as
@(use-mathjax) @${x^2}. @(use-mathjax) @${x^2}.
The syntax accepted by @racket[$] is a subset of the The syntax accepted by @racket[$] is a subset of the
@ -65,11 +67,14 @@ documentation for @racket[with-html5] for more details.
details, see their respective documentation.} details, see their respective documentation.}
@defproc[($$ [str string?] ...) element?]{ @defproc[($$ [str string?] ...) element?]{
Renders the given strings as display math (centered, alone Renders the given strings as @deftech{display mode} math.
on its line), using MathJax or KaTeX for the HTML output, Display mode math is typeset alone on its line, and is
depending on the current configuration. For the LaTeX centered. Some symbols like @${\sum} are larger in display
output, the code is simply passed as-is. For example, when mode than in @tech{inline mode}, which makes the former better for
using MathJax, complex equations. Either MathJax or KaTeX is used for the
HTML output, depending on the current configuration. For
the LaTeX output, the code is simply passed as-is. For
example, when using MathJax,
@racketblock[($$ "\\sum_{i=0}^n x_i^3")] @racketblock[($$ "\\sum_{i=0}^n x_i^3")]
@ -107,56 +112,57 @@ documentation for @racket[with-html5] for more details.
@defparam[$-html-handler handler (→ (listof? string?) element?) @defparam[$-html-handler handler (→ (listof? string?) element?)
#:value $-katex]{ #:value $-katex]{
A parameter whose values is a function called by A parameter whose value is a function called by @racket[$],
@racket[$], to transform the math code into HTML. The to transform the math code into HTML. The @racket[$]
@racket[$] function uses this parameter only when rendering function uses this parameter only when rendering the
the document as HTML.} document as HTML.}
@defparam[$$-html-handler handler (→ (listof? string?) element?) @defparam[$$-html-handler handler (→ (listof? string?) element?)
#:value $$-katex]{ #:value $$-katex]{
A parameter whose values is a function called by A parameter whose value is a function called by
@racket[$], to transform the math code into HTML. The @racket[$$], to transform the math code into HTML. The
@racket[$] function uses this parameter only when rendering @racket[$$] function uses this parameter only when
the document as HTML. rendering the document as HTML. }
}
@defproc[($-katex [math (listof? string?)]) element?]{ @defproc[($-katex [math (listof? string?)]) element?]{
Produces an @racket[element?] which contains the given Produces an @racket[element?] which contains the given
@racket[math] code, so that it is rendered as inline math @racket[math] code, so that it is rendered as @tech{inline
using KaTeX. More precisely, the resulting element uses mode} math using KaTeX. More precisely, the resulting
several scribble properties to add scripts and stylesheets element uses several scribble properties to add scripts and
to the document. The resulting element also uses a specific stylesheets to the document. The resulting element also
CSS class so that when the page is loaded into a browser, uses a specific CSS class so that when the page is loaded
KaTeX can recognise it and render it in inline mode.} into a browser, KaTeX can recognise it and render it in
@tech{inline mode}.}
@defproc[($$-katex [math (listof? string?)]) element?]{ @defproc[($$-katex [math (listof? string?)]) element?]{
Produces an @racket[element?] which contains the given Produces an @racket[element?] which contains the given
@racket[math] code, so that it is rendered as display math @racket[math] code, so that it is rendered as @tech{display
(centered, alone on its line) using KaTeX. More precisely, mode} math (centered, alone on its line) using KaTeX. More
the resulting element uses several scribble properties to precisely, the resulting element uses several scribble
add scripts and stylesheets to the document. The resulting properties to add scripts and stylesheets to the document.
element also uses a specific CSS class so that when the The resulting element also uses a specific CSS class so
page is loaded into a browser, KaTeX can recognise it and that when the page is loaded into a browser, KaTeX can
render it in display mode.} recognise it and render it in @tech{display mode}.}
@defproc[($-mathjax [math (listof? string?)]) element?]{ @defproc[($-mathjax [math (listof? string?)]) element?]{
Produces an @racket[element?] which contains the given Produces an @racket[element?] which contains the given
@racket[math] code, so that it is rendered as inline math @racket[math] code, so that it is rendered as @tech{inline
using MathJax. More precisely, the resulting element uses mode} math using MathJax. More precisely, the resulting
several scribble properties to add scripts and stylesheets element uses several scribble properties to add scripts and
to the document. The resulting element also uses a specific stylesheets to the document. The resulting element also
CSS class so that when the page is loaded into a browser, uses a specific CSS class so that when the page is loaded
MathJax can recognise it and render it in inline mode.} into a browser, MathJax can recognise it and render it in
@tech{inline mode}.}
@defproc[($$-mathjax [math (listof? string?)]) element?]{ @defproc[($$-mathjax [math (listof? string?)]) element?]{
Produces an @racket[element?] which contains the given Produces an @racket[element?] which contains the given
@racket[math] code, so that it is rendered as display math @racket[math] code, so that it is rendered as @tech{display
(centered, alone on its line) using KaTeX. More precisely, mode} math (centered, alone on its line) using KaTeX. More
the resulting element uses several scribble properties to precisely, the resulting element uses several scribble
add scripts and stylesheets to the document. The resulting properties to add scripts and stylesheets to the document.
element also uses a specific CSS class so that when the The resulting element also uses a specific CSS class so
page is loaded into a browser, MathJax can recognise it and that when the page is loaded into a browser, MathJax can
render it in display mode.} recognise it and render it in @tech{display mode}.}
@defproc[(use-katex) void?]{ @defproc[(use-katex) void?]{
This shorthand calls @racket[($-html-handler $-katex)] This shorthand calls @racket[($-html-handler $-katex)]
@ -166,7 +172,7 @@ documentation for @racket[with-html5] for more details.
KaTeX. KaTeX.
The KaTeX library will be added to the HTML document only The KaTeX library will be added to the HTML document only
if is uses the result of one of @racket[$], @racket[$$], if it uses the result of one of @racket[$], @racket[$$],
@racket[$-katex] or @racket[$$-katex]. It is therefore safe @racket[$-katex] or @racket[$$-katex]. It is therefore safe
to call this function in libraries to change the default to call this function in libraries to change the default
handler, without the risk of adding extra resources to the handler, without the risk of adding extra resources to the
@ -180,9 +186,8 @@ documentation for @racket[with-html5] for more details.
later in the document will therefore be typeset using later in the document will therefore be typeset using
MathJax. MathJax.
The MathJax library will be added to the HTML document only The MathJax library will be added to the HTML document only
if is uses the result of one of @racket[$], @racket[$$], if i uses the result of one of @racket[$], @racket[$$],
@racket[$-katex] or @racket[$$-katex]. It is therefore safe @racket[$-katex] or @racket[$$-katex]. It is therefore safe
to call this function in libraries to change the default to call this function in libraries to change the default
handler, without the risk of adding extra resources to the handler, without the risk of adding extra resources to the
@ -193,11 +198,11 @@ documentation for @racket[with-html5] for more details.
When using MathJax, @racket[$] and @racket[$$] wrap their When using MathJax, @racket[$] and @racket[$$] wrap their
content with @racket["$…$"] and @racket["\\[…\\]"] content with @racket["$…$"] and @racket["\\[…\\]"]
respectively, and insert it in an element with the style respectively, and insert it in an element with the class
@racket["tex2jax_process"]. MathJax is configured to only @racket["tex2jax_process"]. MathJax is configured to only
process elements with this class, so it is safe to use process elements with this class, so it is safe to use
@tt{$} signs in the source document. For example, the text @tt{$} signs in the source document. For example, the text
$\sum x^3$ is displayed as-is, like the rest of the text. $\sum x^3$ is typeset as-is, like the rest of the text.
@section{Drawing figures with Asymptote} @section{Drawing figures with Asymptote}
@ -207,12 +212,12 @@ $\sum x^3$ is displayed as-is, like the rest of the text.
Renders the figure described by the given strings using Renders the figure described by the given strings using
Asymptote. If @racket[cache?] is @racket[#f], then the Asymptote. If @racket[cache?] is @racket[#f], then the
resulting images are generated into temporary PNG, SVG and resulting images are generated into temporary PNG, SVG and
PDF files are generated using @racket[make-temporary-file]. PDF files using @racket[make-temporary-file]. Otherwise, to
Otherwise, to improve compilation speed, the result is improve compilation speed, the result is cached in the
cached in the @filepath{asymptote-images} directory, based @filepath{asymptote-images} directory, based on a checksum
on a checksum of the strings. It is a good idea to clean up of the strings. It is a good idea to clean up the working
the working directory after experimenting a lot with a directory after experimenting a lot with a figure, as it
figure, as it will be cluttered with stale cached files. will be cluttered with stale cached files.
If the Asymptote code is dynamically generated, make sure If the Asymptote code is dynamically generated, make sure
that the result is always the same, or use that the result is always the same, or use
@ -224,7 +229,7 @@ $\sum x^3$ is displayed as-is, like the rest of the text.
already cached, then the scribble document can be compiled already cached, then the scribble document can be compiled
without installing Asymptote. without installing Asymptote.
As an example, the the code As an example, the code
@scribbleblock|{ @scribbleblock|{
@asymptote{ @asymptote{