pressbooks / pb-mathjax

A replacement for wp.com/latex.php but instead of LaTeX, it uses MathJax.
GNU General Public License v3.0
4 stars 1 forks source link

Latex equation tags displaying smaller than expected in export formats #23

Open mcgratay opened 4 years ago

mcgratay commented 4 years ago

Description It's possible to use commands within latex shortcodes to add a number tag to an equation. This displays well in webbook: Screen Shot 2019-12-13 at 12 22 12 PM

But shrinks the equation size in ebook and PDF file exports: Screen Shot 2019-12-13 at 12 23 24 PM

Changing the font in MathJax settings had no effect on the diminished size of the equations. Note that equations do display larger than this in exports when tags are not added to the equation:

Screen Shot 2019-12-13 at 12 25 01 PM

The only alternative known at this time is increasing the equation manually with size commands (ex: /huge)

Example: https://cloneformathjax.textopress.com/

Steps to Reproduce

  1. Make sure QuickLaTeX is deactivated in your test book
  2. Edit a chapter in visual editor mode to include a tagged equations (ex: [latex]\tag{2.1}R\:=\frac{E}{I}[/latex])
  3. Add another untagged equation for comparision (ex: [latex]a^2=c[/latex])
  4. Save the chapter and export to all supported formats

Expected Behavior: Equations display at optimal size in all supported formats

Actual Behavior: Equations display smaller than normal in export formats when tags are added

tw77 commented 2 years ago

The question of equation size in webbook vs. PDF came up recently for an author at CUNY, though the other way around: equations were shrunk in the webbook. The resizing method we found for the webbook (to match what was in the PDF) was different from the use of LaTeX size commands mentioned here and more granular though still not an ideal solution: resizing equations with styled <p> tags.

The author was using \begin{equation}…\end{equation} to encode display equations (equations centred on their own line) and it was working for the webbook but not the PDF. After switching to supported [latex] delimiters wrapped in centre-aligned <p> tags, these equations were centred on their own line on PDF exports, but this had the effect of shrinking them in the webbook. This was countered by including font size in the <p> tag as well, in this case: <p style="text-align: center; font-size: 113%;">[latex]...[/latex]</p>

113% was the size that worked for Asimov but this would need to vary depending on the theme in use. Even with this approach, the resizing is only approximate since the real sizing of display equations in MathJax happens dynamically. (At this time we aren't able to access this contextual sizing for display equations using our supported delimiters. \begin{equation}…\end{equation} properly renders display equations for Web, but isn't recognized in PDF exports, while [latex]...[/latex] doesn't allow for display equations as far as we know.)

The advantage of using styled <p> tags over size commands here was that it allowed for a bit more control over the resulting size (since there are only 10 standard type size commands supported by LaTeX), but this approach only works for altering size within webbooks.

Ticket for internal reference: https://pressbooks.zendesk.com/agent/tickets/9045