## WeBWorK Problems

### MathJax Equations with Fractions of different sizes

by Paul Seeburger -
Number of replies: 15
I am working with rational equations problems right now and I am finding that the fractions in various parts of the equation are being sized differently by MathJax.

For example, when I give the code:

Solve the equation:
$$\quad \Large { n + \frac{1}{n}= \frac{b}{a}}$$

I get:

Solve the equation:
n+1n=52

Note that the 5/2 is larger than the 1/n.  Sometimes this relative size difference is even greater.

I noticed that image mode seems to level out these differences, but I've been trying to
use MathJax.

Is there anything in the way I am defining the equation that can cause MathJax
to do better?

Thanks!

Paul

### Re: MathJax Equations with Fractions of different sizes

by Dick Lane -
Would

$$\displaystyle n + \frac{1}{n} = \frac{b}{a}$$

be acceptable?

### Re: MathJax Equations with Fractions of different sizes

by Paul Seeburger -
Thanks, Dick!

That seems to have taken care of it! I'll check it out for other problems too.

I appreciate it!

Paul

### Re: MathJax Equations with Fractions of different sizes

by Alex Jordan -

I ask because I can think of a hundred different ways to present this equation with various LaTeX structures. For instance perhaps you'd be happy with just using $...$ instead of $$\quad\Large...$$. But you may have something specific in mind that $...$ doesn't address. In that case, I still think there would be a better way to accomplish it than with \quad\Large, depending on what you want the result to look like.

### Re: MathJax Equations with Fractions of different sizes

by Paul Seeburger -
I don't always like /[ .../] because it centers the formula on a new line. Sometimes I want them on the same line as my instructions.

\quad adds some space between the text and the formula. \Large gives a large font. Is there a better way to do this?

### Re: MathJax Equations with Fractions of different sizes

by Alex Jordan -
Is the goal of \Large to make everything larger than it would otherwise be, or just to make the numerators and denominators the same size as the rest of the math?

My intuition goes against using manual spacing commands like \quad in this way. They will show up in the MathJax output, and potentially cause confusion in the future for a screen reader. Probably not, but it's a possibility. And that's just one concern that I can imagine. There are unimaginably many concerns that I can't imagine, if you take my meaning.

For indentation, if you are using the TEXT environment, I might suggest making an indentation macro: $INDENT =$SPACE.$SPACE.$SPACE. Then use $INDENT before the math environment starts. Either that, or switch to PGML, and then by indenting four spaces in your code, the result is indented on screen and in hard copies. In reply to Alex Jordan ### Re: MathJax Equations with Fractions of different sizes by Paul Seeburger - Thanks, Alex! The \Large does make everything larger than it would otherwise be. I want to make the equation larger than the text so that it will stand out and look better. Particularly when they are in-line, the formulas are sometimes just too small, in my opinion. Are there other ways to make text and formulas larger that would be preferred? I am also not aware of any of the concerns you are referring to. I often have used \quad and \, to get the formulas in my problems to display nicely, with more space between things to clarify them. The defaults are not always spaced out enough to make things clear, in my opinion. Can you use$SPACE in the middle of a TeX formula? \quad gives me more than a single space in a shorter amount of typing.

I am not sure where to find all these secret codes, but slowly I discover them. =)

I only have ever used TeX in the context of WeBWorK, so I am not sure why \quad should cause any trouble. Can you clarify?

Thanks!

Paul

### Re: MathJax Equations with Fractions of different sizes

by Alex Jordan -
A lot of this is my opinions. But at least some of it is best practices.

I'm frankly surprised that \Large has any effect at all, and doesn't cause an error. Apparently this is because MathJax has been developed to understand and give meaning to \Large. However, it won't have the effect you describe for a hard copy or if the user is using images for displaying math. The controls for LaTeX font size are different in math mode than in text mode, and \Large is one of the text mode controls. In math mode, size-based font controls like that don't exist. Instead there are: \displaystyle, \textstyle, \scriptstyle, and \scriptscriptstyle. It's a misunderstanding to think of these as controlling size. They do different things to different types of math mode characters. Still, you can loosely think of them as four sizes available in math mode.

Even if \Large is working with MathJax, I wouldn't use it. Maybe it is just personal choice, but if something is important to the presentation of the problem, I have the philosophy that it needs to be made to happen in all of the output formats (and just to mention it, also work with all of the major browsers). This approach is probably less important here with font size, but is more important if say, while working in Firefox, you were to introduce some kind of fancy css into the on-screen problem that communicates something important to the student, and for which the hard copy would not have a counterpart, or the css was not supported by say Chrome.

In the end I fall on the side of letting the end user pick their font sizes. For the whole problem, they can resize the page if needed. For specifically enlarging the math, if that is something the user wants, they can configure MathJax to do that by right-clicking and then using Math Settings --> Scale all math.

If it is just the fractions that feel too small, then along with what Dick suggests, it is handy to know that \dfrac{a}{b} is a shortcut for {\displaystyle\frac{a}{b}}.

Regarding \quad and other manual spacing commands, part of the trouble is that what aesthetic judgments you make from what you see on your browser don't always apply evenly across the spectrum of browsers, browser release versions, and browser OS versions. I've seen manual spacing adjustment put into the math in .pg problems that look terrible in Firefox on a Mac, but look OK in IE on a PC, for example. (And look somewhere in between in the hard copy.)

The other idea here is to keep the bits of math content as small and tidy as possible, just in case assistive technology like a screen reader can handle small and tidy, but not handle things that are more complex.

John

### Re: MathJax Equations with Fractions of different sizes

by Paul Seeburger -
Thanks, John and Alex, for sharing all the helpful new command options I was unaware of and for some clarification on the pros and cons of some like \Large.

I had assumed that WeBWorK used most TeX commands and have searched online for ways to accomplish various things in TeX.  The \Large command is one of many that I have found in this way that have worked as hoped for in WeBWorK.

You'd mentioned that you thought \Large would not work in images mode, but I've found that it does work there.  MathJax also honors it, it seems, although it is where the fractions seem more likely to be sized differently (without special care to use \displaystyle and TeX instead of Fraction MathObjects).  In general I do find that MathJax is on the small side without adjustment.  I like the larger default size of the images better, but I've still begun trying to use MathJax since I've been told of some of its other advantages such as the screen reader being able to read it.

To be honest, my main concern currently is with the way the problems look and work on-screen.  I want the equation to be larger than the surrounding text so that it stands out and makes it easier for the algebra students to focus on.  Because of this, the browser methods of magnification are not relevant to my goal.  If the text gets larger too, it just crowds out the equation, making it still not stand out as I desire.  I don't choose to do this every time, but in some problems it makes for a cleaner, clearer effect.

I am not really too worried about the size or spacing of the equations or formulas on the PDF version, as long as it is still clear and readable.  The size does not have as much advantage there as on-screen, in my opinion.  But I am still learning a lot... it's a rather long process it seems... about creating WeBWorK problems in the best ways.  If it is taking me this long, I expect that it is even harder for some of my colleagues who are less comfortable with programming (and who like me had never worked with TeX before).  =)

I expect that some of the other commands you've added to my tool-kit today will help me accomplish this current goal in a more standard way.

Thanks again!

Paul

### Re: MathJax Equations with Fractions of different sizes

by Paul Seeburger -
Ok, I've tried the other options for replacing \displaystyle.  That is, \textstyle, \scriptstyle, and \scriptscriptstyle.  They are all really neat and helpful, but they go the wrong direction in making the formula smaller, smaller, and smaller still.  I may wish to use these in the future, but I still need their analogs for making the formula or equation bigger, bigger, and bigger still.  =)

I'm currently sticking with \large (a little smaller than \Large) \displaystyle in front of my equation.  It looks great in both image and MathJax modes on the screen.

Can you suggest style options that will accomplish these larger sizes in a more standard way?

By the way, I found a website that shows \quad being useful and standard in math mode: https://www.sharelatex.com/learn/Spacing_in_math_mode

Another page on this site (linked to from the mathematical fonts page) for controlling font size in formulas and text in latex:  https://www.sharelatex.com/learn/Font_sizes,_families,_and_styles#Font_sizes

It includes \large and \Large, etc.  They are made to look standard here.

Thanks!

Paul

### Re: MathJax Equations with Fractions of different sizes

by Davide Cervone -
The \large, \Large and other similar commands are actually text-mode commands in LaTeX and are not allowed in math mode. They are available in MathJax because they are useful and you don't have the low-level commands available in TeX to make your own font sizes directly. So it is a useful extension. The references you cite illustrate size changes in text-mode, not math-mode.

Note that these macros will have no effect in image mode (if you did $$x\Large x$$, for example, you would have to different sized x's in MathJax, but two same-sized x's in image mode). I would recommend against using \Large and its friends in your WeBWorK problems.

Similarly, \quad is a standard macro and does produce space, but your use of it is to indent, which is not part of the mathematics, but rather part of the layout of the page, and so should not be part of the mathematical markup. While you may get the visual result that you want, it makes it harder for things like screen readers to figure out what you are doing. So that sort of spacing should be avoided. Use the facilities in PG for spacing (or PGML, as others have suggested), rather than inserting non-math material into your mathematics to force indentation.

I agree with others who have said that fiddling with the text size in your problems is a bad idea. If the MathJax font seems small compared to the text, then use the MathJax menu to scale the math for you. Other browsers (and other text font choices) may produce other results for other people, and so when you increase the size to fix it for you, it breaks it for everyone else. Plus if MathJax ever changes and produces better results in your browser, all your problems will now look bad for you.

In general, you should not miscode your problems to work around a browser issue that may be temporary (that is, if you want your problems to be useful in the future). I know it is tempting to do so, but those who have been in this business for a while know that that is a losing battle, and one that just causes more and greater problems in the long run.

### Re: MathJax Equations with Fractions of different sizes

by Paul Seeburger -
Thanks, Davide!

I think I've got the \quad figured out.  My code for the original question happened to use \quad in a non-standard way.  I've already fixed that.  But as others including you have mentioned, \quad is very useful in spacing formulas on the inside.

However, I am still struggling with finding a suitable replacement for the \Large formatting of formulas (when using MathJax, since it often renders smaller than the surrounding text, while image mode automatically is larger than the surrounding text).

Take this problem for example:
Library/Utah/Intermediate_Algebra/set7_Exponential_and_Logarithmic_Functions/s7p14.pg

See the relevant code below.

In the MathJax version of the problem, it appears with the exponents almost too small to read by default.  See image below.  Now, perhaps I am misunderstanding, but it sounds like you and other are suggesting that my wanting to make the equations larger is for my own eyesight and thus I can make it larger in my own browser (as can my students) as needed.  But this isn't my purpose.  I want it to be legible to all my students when they open the problem without needing to know how to magnify a webpage in order to make it easier to read.

When I do insert a \Large to operate on both formulas, they become perfectly sized and legible.  Perhaps I missed it, because I didn't understand the mention of the MathJax menu, but what is the standard way to resize (make larger here) the MathJax font in my problem?

I am already happy with the way the image mode presents these problems (they are already larger), so I am not worried about them not being made larger.

The code at issue is:

TEXT(EV2(<<EOT));
Rewrite the following expressions using just one rational exponent.
Enter the numerator and denominator of the exponent.  Cancel any
common factors.
$BR $$(u^{\frac{3}{2}})^{\frac{4}{5}} = u^{\frac{a}{b}}$$ where $$a=$$ \{ ans_rule(4) \} and EOT ANS(num_cmp(6, mode=>"strict")); TEXT(EV2(<<EOT)); $$b =$$ \{ ans_rule(4) \}. EOT ANS(num_cmp(5, mode=>"strict")); TEXT(EV2(<<EOT));$BR
$$(z^{\frac{4}{3}})^{\frac{9}{2}} = z^{\frac{a}{b}}$$ where
$$a=$$  \{ ans_rule(4) \} and
EOT
ANS(num_cmp(6, mode=>"strict"));
TEXT(EV2(<<EOT));
$$b =$$  \{ ans_rule(4) \}.
EOT

If these were just fractions, I've learned that I can use \displaystyle or \dfrac to make the fractions larger, but in this problem, that makes the fractions too big relative to the bases in the formula and thus it's not a viable solution.

Inserting the \Large before both fractions gave me this version in MathJax mode:

In image mode it still appears fine (as it did before) as:

I appreciate all the new things I have already learned in this thread.  I can understand the desire to make our problems follow standard practice wherever possible too, but my first objective is to make these problems legible and easy to follow for my students.

Perhaps I should just use image mode... but it seems that there are different issues that sometimes arise then in the newer versions of WeBWorK, and MathJax works with screen readers, and it's the standard mode for most users and I would like to use it too.  =)

Thanks so much!

Paul

### Re: MathJax Equations with Fractions of different sizes

by John Jones -
Davide would know the details, but I think you can set the math size magnification level for the server (which users can then override).  It is analogous to the fact that image mode has a site configurable magnification level.

In the examples you post, I don't have a problem reading the exponents of the original, but my initial reaction was that they should be typeset horizontally as just a/b instead of \frac{a}{b}.  With simple fractions like that in the exponent, I think horizontal fractions are considered preferable.  It is a different story in the solution which puts more complicated expressions in the exponents.

John

### Re: MathJax Equations with Fractions of different sizes

by Paul Seeburger -
Thanks, John!

I'm not on my own server, so I guess I am not very aware of these options to configure MathJax.

Writing the exponents horizontally may help here, it's true.

And the PNG images already may be a little larger than life in my post I think, so the exponents might appear a little larger than I was seeing in my problems.

Paul