octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Latex equation support in the documentation created by generate_html


From: Oliver Heimlich
Subject: Re: Latex equation support in the documentation created by generate_html package
Date: Mon, 30 May 2016 14:37:31 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Icedove/38.7.0

On 29.05.2016 22:49, siko1056 wrote:
> Dear Fernando,
> 
> I can hardly add anything to this conversation.
> 
> * No 30 MB Javascript needs to be included, too many people are 24/7 online
> these days, use the CDN.
> * There should be a PDF version generated by makeinfo attached to a package
> for reading offline / print.
> * I guess rendering issues will be solved with upcoming versions (too many
> projects use MathJax for this not to happen), we have to follow the changes.
> * My biggest concern is the texinfo markup language. As Oliver explained
> @math expands to some emphasize, that would eat brackets {}, and it would
> require something like @verb{$My math$} to get the LaTeX through makeinfo or
> texi2pdf.
> 
> 
> I uploaded a modified part of the Octave documentation, where the effort of
> including MathJax should become obvious
> 
> Exponents_and_Logarithms_mathjax.html
> <http://octave.1599824.n4.nabble.com/file/n4677253/Exponents_and_Logarithms_mathjax.html>
>   
> 

Kai,

thanks for providing an example. Please find attached the same example,
but with HTML5 (MathML is part of HTML5) instead of MathJax. I have
changed the doctype to <!DOCTYPE HTML> and converted the math from Tex
syntax into a <math> structure (which could be automated by some tool
and could be integrated into Texinfo).

The main drawback of MathML would be that it is only supported by Gecko
browsers (however, this is not going to change if everybody prefers
MathJax over MathML). The main drawback of MathJax is that it requires
Javascript.


Back to MathJax:

I'd like to keep additional “LaTeX” fonts out of the website. These make
sense in a printed document, but on a low definition device (most
computer monitors) they add to the problem of rendering the characters
and also don't fit into the sans-serif fonts that we currently use.

Also I dislike that MathJax increases the font-size by 13% in your
example. I found out that this comes from a feature that tries to match
font heights (and does a bad job IMHO).

I could achieve a better result in MathJax for all renderers (see
screenshot attached) except SVG with the following CSS:

/* Common HTML and Preview HTML renderers do not support styles */
.MJXc-TeX-main-R, .MJXp-math {font-family: inherit !important}
.MJXc-TeX-math-I {font-family: inherit !important; font-style: italic;}


… and extended load script:

  MathJax.Hub.Config({
    tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]},
    /* don't download LaTeX fonts */
    webfont: null,

    /*
        don't increase font size of math in contrast to regular text
        and use custom fonts from the surrounding text
     */
    CommonHTML: {
        matchFontHeight: false,
        mtextFontInherit: true
    },
    "HTML-CSS": {
        matchFontHeight: false,
        mtextFontInherit: true,
        styles: {
            ".mi, .mn, .mo": {
                "font-family": "inherit !important"
            }
        }
    },
    NativeMML: {
        matchFontHeight: false,
        styles: {
            "math": {
                /* This affects upright characters and numbers only */
                /* I don't know how to affect other glyphs */
                "font-family": "inherit"
            }
        }
    },
    PreviewHTML: {
        mtextFontInherit: true
    }

    });


Best
Oliver

17.1 Exponents and Logarithms

Mapping Function: exp (x)

Compute e^x, now with MathML, ex = lim n ( 1 + x n ) n for each element of x.

To compute the matrix exponential, see Linear Algebra.

See also: log.

Mapping Function: expm1 (x)

Compute exp (x) - 1 accurately in the neighborhood of zero.

See also: exp.

Mapping Function: log (x)

Compute the natural logarithm, ln (x), for each element of x.

To compute the matrix logarithm, see Linear Algebra.

See also: exp, log1p, log2, log10, logspace.

Function File: reallog (x)

Return the real-valued natural logarithm of each element of x.

If any element results in a complex return value reallog aborts and issues an error.

See also: log, realpow, realsqrt.

Mapping Function: log1p (x)

Compute log (1 + x) accurately in the neighborhood of zero.

See also: log, exp, expm1.

Mapping Function: log10 (x)

Compute the base-10 logarithm of each element of x.

See also: log, log2, logspace, exp.

Mapping Function: log2 (x)
Mapping Function: [f, e] = log2 (x)

Compute the base-2 logarithm of each element of x.

If called with two output arguments, split x into binary mantissa and exponent so that 1/2 <= abs(f) < 1 and e is an integer. If x = 0, f = e = 0.

See also: pow2, log, log10, exp.

Function File: pow2 (x)
Function File: pow2 (f, e)

With one input argument, compute 2 .^ x for each element of x.

With two input arguments, return f .* (2 .^ e).

See also: log2, nextpow2, power.

Function File: nextpow2 (x)

Compute the exponent for the smallest power of two larger than the input.

For each element in the input array x, return the first integer n such that 2^n ≥ abs (x).

See also: pow2, log2.

Function File: realpow (x, y)

Compute the real-valued, element-by-element power operator.

This is equivalent to x .^ y, except that realpow reports an error if any return value is complex.

See also: power, reallog, realsqrt.

Mapping Function: sqrt (x)

Compute the square root of each element of x.

If x is negative, a complex result is returned.

To compute the matrix square root, see Linear Algebra.

See also: realsqrt, nthroot.

Function File: realsqrt (x)

Return the real-valued square root of each element of x.

If any element results in a complex return value realsqrt aborts and issues an error.

See also: sqrt, realpow, reallog.

Mapping Function: cbrt (x)

Compute the real cube root of each element of x.

Unlike x^(1/3), the result will be negative if x is negative.

See also: nthroot.

Function File: nthroot (x, n)

Compute the real (non-complex) n-th root of x.

x must have all real entries and n must be a scalar. If n is an even integer and x has negative entries then nthroot aborts and issues an error.

Example:

nthroot (-1, 3)
⇒ -1
(-1) ^ (1 / 3)
⇒ 0.50000 - 0.86603i

See also: realsqrt, sqrt, cbrt.


Attachment: mathjax-with-custom-fonts.png
Description: PNG image


reply via email to

[Prev in Thread] Current Thread [Next in Thread]