22
$\begingroup$

Sometimes I need to cancel \cancel{} or \enclose{horizontalstrike}{} or change color \color{}{} using methods introduced in this post. Such manipulations should be done in dollar signs and after using \text{}, letters will be shown with different font.

For example:

This is the original. $\text{This is inside dollar signs.}$

Is it possible to avoid this?

Edit: \rm{} or \mathrm{} do the same thing.

| |
$\endgroup$
15
$\begingroup$

The short answer is no. A slightly longer answer is that MathJax uses local fonts since it renders locally, so not every user sees the same font in the first place. (See meta posts asking about MathJax fonts and STIX vs tex fonts).

But I also don't think that there are times when I intermix TeX fonts and regular fonts. You can strike through text without resorting to TeX. If I'm trying to distinguish something by using ${\color{#AA0000}{\text{colors}}}$, then I'm specifically using the different styling and I don't care to make the TeX more similar.

On the other hand, from an abstract standpoint, it is interesting to know whether one can consistently use MathJax to render the exact same font and size. I don't know of it, but I bet that the amazing wizards at TeX.se know.

| |
$\endgroup$
  • 2
    $\begingroup$ IIRC MathJax is off-topic on tex.se (but one could try on SO and the MJ devs read this meta even, at least sometimes). $\endgroup$ – quid May 14 '15 at 1:30
  • $\begingroup$ How does strike through work? I can't find it here. $\endgroup$ – MonkeyKing May 14 '15 at 1:33
  • 1
    $\begingroup$ @MonkeyKing <strike>strike through</strike> is the source-snippet; it does not work in comments though. $\endgroup$ – quid May 14 '15 at 1:35
  • 1
    $\begingroup$ @quid oh is it? That doesn't surprise me too much, I suppose, as it is fundamentally different. But I also ascribe to the belief that reasonable questions might be asked where they would best be answered. MathJax is remarkable. It didn't occur to me that the devs might pass through here from time to time. [If you see this - brilliant, and thank you!] $\endgroup$ – davidlowryduda May 14 '15 at 3:32
  • 1
    $\begingroup$ @mixedmath: the devs do pass this way, and if I recall, they do not support using MathJax to enhance images or non-math text (the reason that I remember dealt with reading software for the visually impaired). I was told not to center images by starting a line with $\hspace{...}$. I would think using the cancel package would also be against their recommendation, unless used in math. $\endgroup$ – robjohn May 14 '15 at 5:58
  • 6
    $\begingroup$ It is possible for SE to configure MathJax to use the surrounding text font within \text{} and other text-creation commands, but they have not done so. Perhaps it is because there is a performance penalty associated with it, or perhaps it is because their configuration was developed before this option was available. It is possible to force the font using the \style{} macro, but if SE ever changed their CSS, your text would not reflect the change. @robjohn is correct that we don't recommend using MathJax in this way, and screen readers is one of the important reasons. $\endgroup$ – Davide Cervone May 14 '15 at 9:24
  • 1
    $\begingroup$ For MJ on tex.se see its tagwiki for the MJ dev see the comment above. :-) Besides Davide Cervone there is also Peter Krautzberger that is affiliated with MJ and on this site. (Perhaps there are more but these two I know about.) $\endgroup$ – quid May 14 '15 at 10:21
25
$\begingroup$

Sure, it is possible. Take a look below, the second line is in MathJax.

Hello, World!
$\style{font-family:inherit;}{\text{Hello, World!}}$

You can right click the second line and select Show Math As > TeX Commands to see the code to produce it: \style{font-family:inherit;}{\text{Hello, World!}}

$$\sum_{n=0}^\infty\frac1{n!}\hspace{20px}\style{font-family:inherit;}{\text{You can use it in display mode as well.}}\hspace{20px}\sum_{n=0}^\infty\frac1{n!}$$

Davide Cervone points out in a comment that using the \style macro would force a specific font, which would be undesirable should MSE ever change to a different font. However, you can set the font to be inherited from the parent element. This way, even if MSE does change the font, this change should be reflected in your post.

| |
$\endgroup$
  • 5
    $\begingroup$ That is sneaky and devious. I like it. :) $\endgroup$ – Ilmari Karonen May 19 '15 at 11:23
  • 1
    $\begingroup$ I think it could make sense to put the code in a visible way. too like $\style{font-family:inherit}{\text{Hello, World!}}$ Not everybody can see the source. [On reflection everybody could see the source but some might not know they can.] $\endgroup$ – quid May 19 '15 at 15:32
  • 1
    $\begingroup$ Davide Cervone also points out in the same comment that "we don't recommend using MathJax in this way, and screen readers is one of the important reasons." $\endgroup$ – user856 May 19 '15 at 15:58
  • 1
    $\begingroup$ @Rahul: That is in response to robjohn, who said "they do not support using MathJax to enhance images or non-math text". I don't see why changing the font for math related text (that would be there regardless) would be bad. $\endgroup$ – Regret May 19 '15 at 16:34
  • 1
    $\begingroup$ Fair enough. ${}$ $\endgroup$ – user856 May 19 '15 at 18:38
  • $\begingroup$ Alas, with the new Common HTML math renderer, the font size seems to be mismatched. :( $\endgroup$ – Ilmari Karonen May 19 '16 at 17:24

You must log in to answer this question.

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