1 m4_dnl ----------------------------------------------------------------------
2 m4_dnl M4 macros for expressing mathematical formulas
5 m4_dnl These macros attempt to make it easier to write mathematical formulas
6 m4_dnl for Maxima's user manual so that nice TeX-style formulas can be used
7 m4_dnl for html and pdf docs and plain text for info.
9 m4_dnl For displayed formulas use m4_displaymath(). For inline formulas use
10 m4_dnl m4_math(). For both m4_displaymath and m4_math, the macros MUST start
11 m4_dnl at the beginning of a line. The end of the macro MUST not be followed
12 m4_dnl by any other text either. Thus,
14 m4_dnl Some description m4_math(foo) goes here
16 m4_dnl is incorrect. It must be written
18 m4_dnl Some description
22 m4_dnl The result will appear inline as expected.
24 m4_dnl In general, each macro takes up to 3 args. The first arg for html
25 m4_dnl docs using MathJax. The second arg is for simple text suitable for
26 m4_dnl info (text) formulas, and the third arg is for TeX output. This is
27 m4_dnl optional; if not provided the first arg is used. This occurs if the
28 m4_dnl same TeX formula can be used for both MathJax and TeX. (MathJax
29 m4_dnl supports LaTeX.)
31 m4_dnl It is probably best to quote each arg to these macros like
32 m4_dnl <<<foo>>> to prevent any confusion in parsing the arg, especially if
33 m4_dnl the arg has commas in it.
35 m4_dnl For m4_displaymath, be careful not to have extra blank
36 m4_dnl lines within the formula; Tex may complain about the
39 m4_dnl If m4_math is supposed to end a sentence, use m4_mathdot. If you
40 m4_dnl don't then the ending period is spaced too far from the end of the
43 m4_dnl If you have sevaral inline formulas separated by commas, use
44 m4_dnl m4_mathcomma(). Otherwise, the comma (like a period), is spaced too
45 m4_dnl far from the formula.
47 m4_dnl For other punctuation that follows an inline formula use m4_mathpunc.
48 m4_dnl For example, if the formula is followed by a ":", use
49 m4_dnl "m4_mathpunc(<<<:>>>, ...)" instead of "m4_math(...):".
51 m4_dnl ----------------------------------------------------------------------
52 m4_dnl Maxima has an # operator, so disable comment delimiters completely so
53 m4_dnl we don't accidentally comment out text.
55 m4_dnl Change the quote characters to something that isn't likely to
56 m4_dnl show up in the manual.
57 m4_changequote(`<<<', `>>>')m4_dnl
59 m4_dnl If makeinfo is too old, we don't have @displaymath, so we'll
60 m4_dnl have to use something else.
61 m4_define(<<<m4_no_displaymath>>>,
62 @NO_DISPLAYMATH@)m4_dnl
64 m4_dnl For writing formulas suitable for various output formats. For
65 m4_dnl simplicity two or three arguments are required:
67 m4_dnl 1: HTML output with MathJAX enabled
68 m4_dnl 2: HTML output without MathJax. Also used for info
69 m4_dnl 3: If given, this is for TeX output. If not, then use arg 1.
71 m4_dnl For easiest use, it's best to quote each arg, so use
72 m4_dnl m4_displaymath(<<<arg1>>>, <<<arg2>>>, <<<arg3>>>)
74 m4_dnl m4_displaymath is used for displayed math equations.
76 m4_dnl Be careful not to leave extra blank lines; TeX may complain about the
78 m4_define(<<<m4_displaymath>>>,
80 m4_ifelse(m4_no_displaymath(), <<<true>>>,
92 $$m4_ifelse(<<<$#>>>, <<<3>>>, <<<$3>>>, <<<$1>>>)$$
96 m4_dnl m4_math(jax, info) or m4_math(jax, info, tex)
97 m4_dnl Like m4_displaymath, but this is meant for inline math equations.
98 m4_dnl m4_math MUST start at the beginning of the line and there must be
99 m4_dnl text after m4_math(). The contents of m4_math may cover several
100 m4_dnl lines, but there must not be any text after m4_math.
101 m4_define(<<<m4_math>>>,
103 m4_ifelse(m4_no_displaymath(), <<<true>>>,
111 @math{m4_ifelse(<<<$#>>>, <<<3>>>, <<<$3>>>, <<<$1>>>)}
114 m4_dnl m4_mathpunc(punc, jax, info) or m4_mathpunc(punc, jax, info, tex)
115 m4_dnl This is like m4_math, but `punc` is placed at the end of the formulas
116 m4_dnl so that the punctuation is not separated by too much space.
117 m4_define(<<<m4_mathpunc>>>,
118 <<<m4_ifelse(<<<$#>>>, <<<4>>>,
119 <<<m4_math(<<<$2$1>>>, <<<$3$1>>>, <<<$4$1>>>)>>>,
120 <<<m4_math(<<<$2$1>>>, <<<$3$1>>>)>>>)>>>)m4_dnl
122 m4_dnl m4_mathdot(jax, info) or m4_mathdot(jax, info, tex)
124 m4_dnl Like m4_math, but automatically add a dot at the end of the
125 m4_dnl equation to end a sentence. If you place a dot after m4_math(), there's
126 m4_dnl an extra space in the output that looks weird. This is analogous to mrefdot.
127 m4_define(<<<m4_mathdot>>>,
128 <<<m4_ifelse(<<<$#>>>, <<<3>>>,
129 <<<m4_mathpunc(<<<.>>>, <<<$1>>>, <<<$2>>>, <<<$3>>>)>>>,
130 <<<m4_mathpunc(<<<.>>>, <<<$1>>>, <<<$2>>>)>>>)>>>)m4_dnl
132 m4_dnl Like m4_mathdot, but adds a comma at the end instead of a dot.
133 m4_dnl Using m4_math() followed by a comma leaves an extra space that looks
134 m4_dnl weird. This is analogous to mrefcomma.
135 m4_define(<<<m4_mathcomma>>>,
136 <<<m4_ifelse(<<<$#>>>, <<<3>>>,
137 <<<m4_mathpunc(<<<,>>>, <<<$1>>>, <<<$2>>>, <<<$3>>>)>>>,
138 <<<m4_mathpunc(<<<,>>>, <<<$1>>>, <<<$2>>>)>>>)>>>)m4_dnl