Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • M MathJax
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 304
    • Issues 304
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 15
    • Merge requests 15
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • MathJax
  • MathJax
  • Issues
  • #1883
Closed
Open
Issue created Dec 12, 2017 by Davide P. Cervone@dpvcContributor

Line breaking doesn't occur when first breakpoint is too far past the width

MathJax stops looking for line breaks past a certain distance past the container width. Currently, the value is 1/3 of the container width (so no breaks will occur farther than 1.33 times the width of the container). That works well with page-sized containers, but for very small containers, that might be too small, and should probably be made into a configurable parameter (it is currently hard-coded). It also would be good to only apply that cut-off if a breakpoint has already been found. This is handled at line 153, and several other locations, of the CommonHTML multiline extension (and similar locations for the other output jax). One could make this

while (i < m && (info.scanW < 1.33*CHTML.linebreakWidth || info.w === 0)) {

to make it only apply when a previous breakpoint exists, and the 1.33 could be added to the penalty values (perhaps) at line 36.

Here is a minimal example that shows the issue:

<!DOCTYPE html>
<html>
<head>
<title>MathJax:  MathJax Line Breaks Test</title>
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    "CommonHTML": { linebreaks: { automatic: true } },
    "HTML-CSS": { linebreaks: { automatic: true } },
    "SVG": { linebreaks: { automatic: true } }
  });
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/latest.js?config=MML_CHTML"></script>
</head>
<body style="padding:0 2em; font-size: 150%">

<div style="border:1px solid black; width:50px">
<math xmlns="http://www.w3.org/1998/Math/MathML">
  <mspace width="25px" height=".5em" mathbackground="red"></mspace>
  <mi>x</mi>
  <mo>=</mo>
  <mi>x</mi>
</math>
</div>

<p>

<div style="border:1px solid black; width:50px">
<math xmlns="http://www.w3.org/1998/Math/MathML"> 
  <mspace width="50px" height=".5em" mathbackground="red"></mspace>
  <mi>x</mi>
  <mo>=</mo> 
  <mi>x</mi>
</math>
</div>

</body>
</html>

The first div will line break at the equal sign (since it is less than 1.33 of the div's width away), but the second will not (since the equal sign is more than 1.33 of the div's width from the left).

Assignee
Assign to
Time tracking