Having difficulty maintaining the consistent size of the MathJax math font in relation to the surrounding text

Issue

I am currently using MathJax to display mathematical equations on my webpage:

https://i.sstatic.net/EfvVq.png

The problem I am facing is that I want the math font to appear larger than the surrounding text, as depicted in the image above. However, when viewed on mobile devices, the math font size scales with the screen resolution and becomes extremely small and unreadable. I have tried using Chrome's developer tools to simulate a mobile view, and the issue persists on my Android phone as well:

https://i.sstatic.net/scrVP.png

Minimum Verifiable Example (MVE)

I have created a minimal complete verifiable example, but it does not work properly on platforms like JSFiddle or OneCompiler. This could be due to these platforms rendering the output within an iframe which is not affected by the responsive design settings of Chrome's developer tools. The issue also persists on actual mobile devices. To view a temporary reproduction of the problem, you can visit the following link: here, or copy and paste the code into a new .html file:

<html lang="en">
  <head>
    ... (code truncated for brevity)
  </head>
  <body>
      ... (code truncated for brevity)
  </body>
</html>

Attempts Made So Far

  1. I have attempted to use the !important style rule to make sure that the font size of the math elements remains consistent:

    mjx-math {
      font-size: 1.2em !important;
    }
    

    Despite applying this style through Chrome's developer tools, the issue persisits.

  2. Referring to suggestions from a Google Groups thread (link provided), I disabled the matchFontHeight option for configuring MathJax:

    chtml: {
      scale: 1.2,
      matchFontHeight: false,
    },
    svg: {
      scale: 1.2,
      matchFontHeight: false,
    }
    
  3. I also experimented with setting a specific viewport meta tag:

    <meta name="viewport" content="initial-scale=0.9, maximum-scale=0.9">
    

Although I have tried other solutions as well, many of them were unsuccessful or I may have overlooked some steps. Additionally, there is a lengthy discussion on GitHub regarding a similar issue, but I was unable to extract a viable solution from it.

Answer №1

In a recent comment, I recommended trying to include the following code in the <head> section of the document:

<meta content="width=device-width, initial-scale=1" name="viewport"/>

This suggestion was made in response to scaling issues that can occur on mobile devices and potentially confuse MathJax.

While this solution did help address the issue, it also resulted in an unintended consequence of doubling the font size on the entire page when viewed on mobile devices.

If you're still experiencing problems, you might want to consider adjusting the scale value in the code like so:

<meta content="width=device-width, initial-scale=.5" name="viewport"/>

It's worth experimenting with different options or exploring additional meta tags such as minimum-width, maximum-width, or setting a specific width value. For more information on these options, you can visit this link. Since I'm not very familiar with these alternatives, it may require some trial and error to determine which one works best for your particular situation.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Struggling to establish a default value for an AngularJS select dropdown

I'm diving into the world of AngularJS and facing a challenge with setting a default value on a select box. I've successfully listed objects in the select box and binding it to the model works seamlessly. However, as soon as I introduce a default ...

Dynamic HTML and CSS Table Alignment Techniques

Issue Screenshot: Is there a way to properly align the right column of the table, particularly the Student NRIC row and School's? .formstyled { width:70%; margin-left:5%; } .formstyled input[type=text],input[type=password],text ...

Guide to sending client-to-client notifications in Angular/Ionic with Firebase Cloud Messaging

I am looking to implement client-client push notifications (not server-to-client). My goal is to send a notification when one user messages another. Is this feasible? How can I achieve this using the structure in the Firebase real-time database? Here is a ...

Calendar complete: ActiveRecord::RecordNotFound (Event with 'id' = update not found)

I'm currently facing an issue with integrating FullCalendar into my rails application. Specifically, I am encountering difficulties with saving after performing drag-and-drop actions. Within my application, I have two models - Event and Workout. The ...

Modifying JavaScript prototypes on the fly can lead to troublesome issues

My curiosity has been piqued by the concept of dynamically changing a constructor's prototype in JavaScript, leading me to the findings above. It appears that an already constructed instance does not inherit the properties of the newly changed protot ...

What is the best way to ensure that text highlighting appears consistent on all browsers?

I am facing an issue with the appearance of text highlighting between Chrome and Firefox browsers. Is there a way to ensure consistency in the appearance across all browsers? a { text-decoration: none; font-weight: 900; font-size: 4vw !impo ...

Creating a layout with two divs displayed next to each other using CSS

Just when I thought I had it figured out, my two side-by-side divs are not behaving as intended inside the parent div. Why is the orange "Content" div ending up below the navigation bar? Can anyone spot what I did wrong here? Thank you in advance! CSS: ...

When converting to TypeScript, the error 'express.Router() is not defined' may

Currently, I am in the process of converting my express nodejs project from JavaScript to TypeScript. One of the changes I've made is renaming the file extension and updating 'var' to 'import' for "require()". However, there seems ...

Is there a way to update a single element within an array without triggering a refresh of the entire array?

Is there a way to prevent the component from rerendering every time new data is input? I attempted to memoize each cell but I am still facing the same issue. Any suggestions on how to accomplish this? import React, { useState, memo } from "react&quo ...

Issue arising from background change upon component focus

My component needs to change its background color when focused, but for some reason it's not working. The hover effect works fine, but the focus doesn't. Can anyone assist me with this issue? import { CardContainer } from './styles' in ...

What could be causing Highchart to return the error message "Typeerror: undefined variable byte"?

My current project involves creating a graph using highchart and updating values every second. I am also working on displaying data in Mb, Kb, and Gb format on the graph by developing a function to convert byte values. Here is a snippet of my code: // hi ...

When attempting to click on the dropdown in Bootstrap, there is no content displayed

I am currently practicing Bootstrap and focusing on implementing Dropdowns. However, I am facing an issue where upon clicking the Dropdown button, nothing appears on the screen. Preview when it's not clicked Preview when it's clicked Here is m ...

Sorting prices in descending order using Expedia API

Is there a way to arrange prices in descending order using the response.hotelList[i].lowRate? The provided code is as follows: success: function (response) { var bil = 1; var hotel_size = response.hotelList.length; $('#listD ...

Assigning properties to the constructor using `this.prop`

Within a React class component, I have multiple methods and the component receives various props. I am contemplating whether I should assign each prop as this.propName in the constructor and then access them using this.propName. For your reference, below ...

Click on the button to convert the content of the text area into a variable

Is there a way to capture all the text inside a textarea or input field as a variable upon button click using jQuery or JavaScript? The .select() function doesn't seem to achieve this, instead displaying numerous CSS properties when logged. What app ...

Attempting to select an input field

I'm having trouble clicking on the Select Files button that is nested within a SPAN and Input Tag. Despite using Xpath, Id, and Name, I am unable to successfully click on the button. <span> Select <u>a</u> Files... </span> & ...

Unable to access res.name due to subscription in Angular

Right now, I am following a tutorial on YouTube that covers authentication with Angular. However, I have hit a roadblock: The code provided in the tutorial is not working for me because of the use of subscribe(), which is resulting in the following messag ...

Once chosen, zoom in on the map to view the results

I am facing an issue with multiple selects in my code, where one select depends on the result of another. The ultimate goal is to zoom in on the area that has been searched and found, but unfortunately, it is not functioning as expected. If you'd lik ...

Underline Rows in CSS

When designing my website, I decided to organize the content into rows using CSS instead of tables. To create a line separating each row, I used height:px; for each row manually. However, this method resulted in the line jumping around inconsistently acr ...

Using CSS backdrop-filter to create a unique blurred border effect for your web elements

In my quest for achieving unique visual effects, I have been experimenting with the backdrop-filter and element borders. While it is easy to create an element that blurs its background, I am facing challenges in making the filter affect only the border are ...