2
$\begingroup$

I have tried methods in https://tex.stackexchange.com/questions/759/average-integral-symbol, but none of them seems to work in MathJax. Using $\frac{1}{|A|}\int_A$ seems uncomfortable. Also, horizontal line is preferred. (If MathJax cannot do this, please tell me how to use \fint or \strokedint.) Thanks for your attention!

$\endgroup$
8
$\begingroup$

Willie Wong asked me to comment on this, but I needed longer than a comment, so am using an answer.

Both Golbez and Willie Wong are correct about what they see, even though they see different things. The problem is that the MathJax web fonts don't include the character U+2A0D (FINITE PART INTEGRAL), so when you use \unicode{x2A0D} or the unicode character directly, MathJax doesn't have the character to display. In that case, it makes a generic unicode reference in hopes that the browser will be able to find the character in some font installed on the user's computer. There is no guarantee that there is such a font, or even if there is, that the browser will find it (the success of this varies across browsers and operating systems, and mobile devices are particularly unlikely to have the needed characters). Even if there is a font with the character, it may not look exactly like the one you see, and may be smaller or larger than the surrounding mathematics, for example, or may be at a different slant. For instance, Willie Wong's post appears with a text-sized version of the integral for me (as opposed to a display-sized one).

So using \unicode means that it is likely that not all users will be able to see what you do, and you are taking a risk when you do that. The STIX fonts do have much greater character coverage, and with v2.3, we do include web-based versions of these fonts, though the default is still the TeX fonts. Math.SE could elect to change to the STIX web fonts in order to get the greater coverage, but many people find the STIX fonts aesthetically unpleasing, and there would likely be an uproar if they did. We can't currently mix the two fonts, but we are hoping to make that possible in a future version of MathJax, so that the TeX fonts can be used for moth things, and when a character is needed that they don't cover, it can be taken form the STIX web fonts. But that is in the future.

For this particular character, it is possible to do some terrible hacks to get it. It is generally considered a bad idea to do it this way, but it can be done. For example, you can use

\def\avint{\mathop{\,\rlap{-}\!\!\int}\nolimits} \avint_A f(x)\,dx = 1

to get something like what you want:

$$\def\avint{\mathop{\,\rlap{-}\!\!\int}\nolimits} \avint_A f(x)\,dx = 1$$

One problem with this is that it only works well in display style. The overlapping is wrong if you use text mode, where you might be better off with something like

\def\avint{\mathop{\rlap{\raise.15em{\scriptstyle -}}\kern-.2em\int}\nolimits}

to get

$$\textstyle \def\avint{\mathop{\rlap{\raise.15em{\scriptstyle -}}\kern-.2em\int}\nolimits} \avint_A f(x)\,dx = 1$$

There are similar problems if you then use either one in a superscript, or a super-superscript.

Fortunately, $\rm\TeX$ provides a \mathchoice macro that allows you to specify a different result for each of the four styles (displaystyle, textstyle, scriptstyle, and scriptscriptstyle). So you can use

\def\avint{\mathop{\mathchoice{\,\rlap{-}\!\!\int}
                              {\rlap{\raise.15em{\scriptstyle -}}\kern-.2em\int}
                              {\rlap{\raise.09em{\scriptscriptstyle -}}\!\int}
                              {\rlap{-}\!\int}}\nolimits}

to get a version that works in any position. But that is pretty ugly, and not something you would want to include often.


In terms of installing the STIX fonts, there are now several forms of the STIX fonts, and MathJax can only use some of them. In particular, the original STIX fonts came as 29 separate fonts with names like STIXGeneral, STIXVariants, STIXSizeOneSym, and so on. These are the ones that MathJax will use if they are installed locally. Several years ago, the STIX fonts were repackaged for use with MS Word as five fonts (in two families, STIX and STIXMath). Unfortunately, MathJax can not make use of these fonts, because not all the characters in them are accessible to the browser, including some that are crucial to MathJax. So if you install these STIX fonts, then MathJax will simply ignore them. I suspect that is what Golbez has done, which is why they are not making any difference for him.

As for SVG output, the SVG renderer uses the same MathJax fonts as the HTML-CSS renderer, so when you specify a unicode character that isn't in those fonts, the SVG renderer will try to make a generic reference to a unicode character and hope the browser finds one, just as the HTML-CSS renderer does. I would expect both to either work or to produce the missing character symbol, but it is possible that that the browser's SVG text handler works differently from the HTML one, and so the it works in one and not the other. I haven't done a comprehensive investigation.


Concerning which web font is used, as of version 2.3 there are now several choices for web font (there used to be only one). There is a hidden menu item that allows you to select the web font to use. You can turn on this menu item (temporarily) by entering

MathJax.Menu.showFontMenu(true)

in your browser's console window. Then when you right-click on an equation, there should be a "Font Preference" menu in the "Math Settings" submenu. Selecting "STIX (web)" should get you the widest coverage, without having to install STIX fonts locally (of course, this will use STIX fonts for everything, which you might not like). Once you select a font, the page will be reloaded, and the font menu will be hidden again, so to change back, you will need to issue the command above again.

$\endgroup$
  • $\begingroup$ Thank you! This method works for me! $\endgroup$ – Golbez Jan 24 '14 at 5:29
3
$\begingroup$

Contrary to what you wrote in the question, this answer works. You just need to copy and paste the appropriate symbol (or learn how to enter unicode symbols using your keyboard).

As an example:

$⨍$ produces $⨍$, which you can also access as $\unicode{x2a0d}$: $\unicode{x2a0d}$

The displayed variant is long, like it should be $$⨍_A f(x)\mathrm{d}x = 1 $$ compare with $$\int_A f(x) \mathrm{d}x = |A| $$


If you are composing a long post and want to make typing slightly simpler, consider defining a new command:

$\newcommand{\avint}{⨍}$
$\avint_A f(x) \mathrm{d}x$

gives

$\newcommand{\avint}{⨍}$ $\avint_A f(x) \mathrm{d}x$.

$\endgroup$
  • 1
    $\begingroup$ In general, as was noted in my previous answer, if the symbol is a math character in Unicode, it can be natively supported by MathJax. $\endgroup$ – Willie Wong Jan 23 '14 at 14:07
  • $\begingroup$ @Golbez: since that character is the average integral symbol, no matter what other ways you choose, as long as MathJax thinks it is the average integral symbol you will still "have the problem". That it is showing up as a square is a font problem. Consider installing an appropriate font instead. $\endgroup$ – Willie Wong Jan 23 '14 at 14:11
  • $\begingroup$ You wrote: The displayed variant is long, like it should be. In fact, I see this. $\endgroup$ – Martin Sleziak Jan 23 '14 at 14:12
  • $\begingroup$ @MartinSleziak: are you using STIX fonts or webfonts? On Debian with STIX fonts all of my browsers (Firefox, Chrome, Konqueror) render it correctly. Or perhaps you are using the image (SVG) rendering instead of either MathML or HTML/CSS? (Hum, that it fails in SVG mode is probably a bug.) $\endgroup$ – Willie Wong Jan 23 '14 at 14:15
  • $\begingroup$ Both HTML/CSS (which was used when I have taken the screenshot) and SVG display small symbol of average integral. If I choose MathML as Math-Renderer, the average integral is indeed larger. I do not know anything about STIX fonts, so I can't answer your question about fonts. $\endgroup$ – Martin Sleziak Jan 23 '14 at 14:19
  • $\begingroup$ Is this part of MathJax configuratoin preferredFont: "TeX" the thing which decides which font is used? $\endgroup$ – Martin Sleziak Jan 23 '14 at 14:21
  • $\begingroup$ @Martin The preferredFont command tells which of the "local" fonts is preferred. See docs.mathjax.org/en/latest/options/HTML-CSS.html But more likely the situation is that you don't have either installed so that the system falls back on web-based fonts or image fonts both of which defaults to the 'TeX' family. I've pinged Davide and maybe he can say a bit more about it. (I only dabble in MathJax enough to use it.) $\endgroup$ – Willie Wong Jan 23 '14 at 14:28
  • $\begingroup$ Thank you! I have downloaded the STIX font and installed all the .otf in the folder.I have restarted my computer, but this character is still a little square. I'm using Windows 7 and Chorme. Is there something wrong? $\endgroup$ – Golbez Jan 23 '14 at 14:37
  • $\begingroup$ My problem now is that IE can render it as Martin did, and Chorme cannot render it and display as a little box. Maybe I should change my preferredFont ? $\endgroup$ – Golbez Jan 23 '14 at 15:13
  • $\begingroup$ @Golbez: I'm not sure. The real resident expert in MathJax issues is Davide Cervone. I've contacted him; hopefully he will be able to fully solve your problem. $\endgroup$ – Willie Wong Jan 23 '14 at 15:26
  • $\begingroup$ Okay,Thank you very much! $\endgroup$ – Golbez Jan 23 '14 at 15:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .