Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The line break(\\) is not work #2312

Open
woody-li opened this issue Oct 2, 2019 · 59 comments
Open

The line break(\\) is not work #2312

woody-li opened this issue Oct 2, 2019 · 59 comments
Labels
Code Example Contains an illustrative code example, solution, or work-around v3
Milestone

Comments

@woody-li
Copy link

woody-li commented Oct 2, 2019

The latex:
x = a + b \\ y = b + c
The line-break isn't effect and it renders as single line.
However, it works fine and renders as two lines at verision 2.

@dpvc
Copy link
Member

dpvc commented Oct 2, 2019

Linebreaks are not yet implemented in version 3. This is one of the significant features from version 2 that has not yet been ported to version 3.

@woody-li
Copy link
Author

woody-li commented Oct 3, 2019

Is it possible to update the support information in the symbols table at http://docs.mathjax.org/en/v3.0-latest/input/tex/macros/index.html .
Any schedule to implement the linebreak?

@dpvc
Copy link
Member

dpvc commented Oct 4, 2019

I'm not sure what you want changed there. The macros are simply listed, and since \\ is used within multi-line environments, it needs to be listed there. There is a link to Carol Fisher's page about the macros (written for v2), but that is not something we maintain, so she would have to maintain it.

In any case, it is not a TeX issue, but an output issue, and the fact that line breaking isn't implemented is documented in several places.

Any schedule to implement the linebreak?

It will be next year, probably in the first half of the year, but there is no specific timetable at the moment.

@dpvc
Copy link
Member

dpvc commented Oct 4, 2019

In the meantime, you can do something like

\displaylines{x = a + b \\ y = b + c}

to get multiple lines

@woody-li
Copy link
Author

woody-li commented Oct 4, 2019

Thanks for your reply.
The \displaylines solved my problem.

The information I said that adding a column in the macros table to show the support version.

@SeanFlemingMathsPathway
Copy link

I'm not sure if it is helpful, but I also found the use of \display{align} honours the newline instruction as well.

\begin{align}2x+y&=5\\y&=-2x+5\end{align}

This also requires the addition of the '&' before the alignment point, and has the benefit of making the equations more readable in our use case.

@T-Kuhn
Copy link

T-Kuhn commented Feb 4, 2020

For some reason, I had to add a third / on my environment (Japanese WordPress blog.)
This didn't work (everything was rendered on the same line):

\displaylines{x = a + b \\ y = b + c}

This worked (2 lines):

\displaylines{x = a + b \\\ y = b + c}

@dpvc
Copy link
Member

dpvc commented Feb 4, 2020

@T-Kuhn, WordPress uses \ as a special character, and it is often stripped out of WordPress posts (depending on what editor you are using). As an escape character, it can prevent the normal action of the character that follows it, so to get an explicit backslash into your post, you need to double it. That is why you need an extra backslash (because the first two equal a single backslash in the output). You probably should double the second one as well, but apparently that is not required.

@dpvc
Copy link
Member

dpvc commented Feb 4, 2020

I'm moving this issue to the main MathJax issue tracker so that it can be found more readily by others.

@dpvc dpvc transferred this issue from mathjax/MathJax-src Feb 4, 2020
@T-Kuhn
Copy link

T-Kuhn commented Feb 5, 2020

@dpvc Thanks for your reply. In the meantime, I figured out that the third backslash is only required if the "Using Markdown" toggle on our specific WordPress blog is set to "on". So, at least in my case, this was a problem between different plugins interfering with each other. Seems like the backslash get's handled as an escape character in Markdown mode on our blog.

@dpvc
Copy link
Member

dpvc commented Feb 5, 2020

@T-Kuhn, yes, Markdown uses the backslash as an escape character. You may also need to be concerned about underscores, as these are used to indicate italics. So you may need to do things like x\_1 rather than x_1 in some situations.

@woody-li
Copy link
Author

Any update or schedule about it?

@dpvc
Copy link
Member

dpvc commented Jun 22, 2020

@woody-li, there is a 3.1 update that is nearly ready to release (hope to have it out by the end of the month). The next release should be at the end of the summer, and will mainly be the long-awaited additional font support for v3 (including STIX2 support and tools for building the data needed for supporting other web fonts). So line breaking and other features will most likely have to wait until next year.

@TheSil
Copy link

TheSil commented Sep 12, 2020

Would it be bad of an idea to add referrence to this task to "Not Yet Ported to Version 3" section in the documenation, for those who go there and want to know status of those items, and possibly for other items on the list? (I assume this ticket is representative for the "Currently, automatic line breaking support is missing from version 3. This is a key feature to be included in a future release." bullet).

@q2apro
Copy link

q2apro commented Sep 15, 2020

So line breaking and other features will most likely have to wait until next year.

That's the reason why nearly nobody is using MathJax 3. I would put it as highest priority if you want to distribute MathJax 3 and see it being successful. I nearly swapped to Katex because of this missing feature, and maybe will do so. However, Mathjax is still my favorite (bolder font, line break of Jax 2 and other features).

@Humam-Hamdan
Copy link

So, still not working...

@dpvc
Copy link
Member

dpvc commented Jul 25, 2023

@Humam-Hamdan, line breaking support is in v4.0-alpha released last year, and in the 4.0-beta released last week. The official v4.0 is planned for the end of August.

@Humam-Hamdan
Copy link

@dpvc ok, thx

@Humam-Hamdan
Copy link

@dpvc Hi again, currently on ver 4.1. but still not working.
$$f(x)=c;c \in \mathbb{R} \newline \mathbb{L} = \{y|y=c; c \in \mathbb{R}}$$
image

@nhpf
Copy link

nhpf commented Dec 7, 2023

@Humam-Hamdan it seems you missed a backslash at the end. You should have \mathbb{R}\} instead of \mathbb{R}}. Also, change \newline to \\. Hope this helps!

@Humam-Hamdan
Copy link

Well, it didn’t, tried the double slashes but sadly didn’t work.

@nhpf
Copy link

nhpf commented Dec 7, 2023

@Humam-Hamdan ok. What version of MathJax are you using? Please provide a minimal reproducible example if you can.

For example, if you open the following HTML file in your browser, you should see the equation properly rendered. The line break error will still be present if you replace the MathJax version 4.0.0-beta.3 by version 3.

<html>
  <head>
    <script>
      MathJax = {
        tex: {
          inlineMath: [
            ["$", "$"],
            ["$$", "$$"],
          ],
        },
        svg: { fontCache: "global" },
      };
    </script>
    <script
      id="MathJax-script" async
      src="https://cdn.jsdelivr.net/npm/mathjax@4.0.0-beta.3/tex-mml-chtml.js"
    ></script>
  </head>
  <body>
    $$f(x)=c;c \in \mathbb{R} \\ \mathbb{L} = \{y|y=c; c \in \mathbb{R}\}$$
  </body>
</html>

@dpvc
Copy link
Member

dpvc commented Dec 7, 2023

@Humam-Hamdan, there is no version 4.1, so I'm not sure which version you are using (4.0.0-alpha.1 maybe?). @nhpf's file works for me as expected, as it does when I change to 4.0.0-alpha.1 (and add the es5 directory), in case that's what you were using. It also works at 4.0.0-beta.4, which is the current beta release. This is an even smaller test file:

<!DOCTYPE html>
<html>
  <head>
    <script
      id="MathJax-script" async
      src="https://cdn.jsdelivr.net/npm/mathjax@4.0.0-beta.4/tex-chtml.js"
    ></script>
  </head>
  <body>
    $$f(x)=c;c \in \mathbb{R} \newline \mathbb{L} = \{y|y=c; c \in \mathbb{R}\}$$
  </body>
</html>

@Humam-Hamdan
Copy link

i copied and pasted the code, and here's the result.
also, i'm on version 0.4.1 (stable)
image

@dpvc
Copy link
Member

dpvc commented Dec 7, 2023

i'm on version 0.4.1 (stable)

This is not a MathJax version. What is it really that this is the version of? Some MathJax plugin for your content-management system?

Also, the output you show is not the output from the file that either @nhpf or I sent you, as the blackboard bold characters are different in the v4.0 beta versions.

When you say you copied and pasted, did you create a new blank file, say test.html on your local computer disk and past the examples into that, save it, and open the local file in a browser? Or did you past it into some content-management system that you are using? You should do the former, not the latter.

@Humam-Hamdan
Copy link

Humam-Hamdan commented Dec 7, 2023

Oh Ok, I'm on obsidian, Thanks.

@CaneMandarinesco
Copy link

2024 and still no fix?
immagine

@dpvc
Copy link
Member

dpvc commented Jan 28, 2024

still no fix?

@CaneMandarinesco, line breaking is supported in v4, which is currently in beta release. There will be at least one more beta version before an official release. The current beta is pretty close to the final version, but as this is a major update, all the ducks need to be in a row, and things have been pushed back, from our earlier planned release date.

@JWock82
Copy link

JWock82 commented Apr 7, 2024

This affects the latest version of Jupyter lab. I'm finding my \\ backslashes are ignored in array cells. It used to work.

@Nambers
Copy link

Nambers commented Oct 20, 2024

Any update on releasing? It been some months

@sowiso
Copy link

sowiso commented Oct 25, 2024

To work around this, I'm trying to wrap any math that contains the \\ pattern in \displaylines{ math }.
In v2, I could manipulate the math using AuthorInit, but v3 does not support that any more. Could anyone help me with how to get this done in v3, so manipulate the math before it gets rendered?

For reference, this is what works in v2 (but the for wrapping displaystyle{}):

    AuthorInit: function () {
        MathJax.Hub.Register.StartupHook('TeX Jax Ready', function () {
            var TEX = MathJax.InputJax.TeX;
            var PREFILTER = TEX.prefilterMath;
            TEX.Augment({
                prefilterMath: function (math, displaymode, script) {
                    math = '\\displaystyle ' + math;
                    return PREFILTER.call(TEX, math, displaymode, script);
                }
            });
        });
    }

@dpvc
Copy link
Member

dpvc commented Oct 27, 2024

Any update on releasing? It been some months

I know it is frustrating to have to wait for this; I'm frustrated by it as well. We have made several beta releases this year, but the final release is still not ready. We are dealing with some issues with the changes made in the assistive technology support that still need to be worked out, and it is taking longer than anticipated. there will need to be one more beta release before the official v4. The betas are in use in production sites, so if the need is urgent, you could consider that. The current beta.7 is pretty close to the final version, and the beta.4 release predates the problems that we are working on, if you want to try those out.

@dpvc
Copy link
Member

dpvc commented Oct 27, 2024

To work around this, I'm trying to wrap any math that contains the \\ pattern in \displaylines{ math }.

Of course, there are uses of \\ that should not be put into \displaylines, such as \begin{align}...\end{align} blocks, but you might be able to filter those out.

In any case, the v3 approach for your situation is to use the startup.ready function in your MathJax configuration. For example:

MathJax = {
  startup: {
    ready() {
      MathJax.startup.defaultReady();
      MathJax.startup.document.inputJax[0].preFilters.add(({math}) => {
        if (math.math.match(/\\\\/)) {
          math.math = `\\displaylines{${math.math}}`;
        }
      });
    }
  }
}

is a simple version that does what you ask, but could be made more sophisticated to avoid the environments that use \\ already for line breaking.

@dpvc dpvc added the Code Example Contains an illustrative code example, solution, or work-around label Oct 27, 2024
@sowiso
Copy link

sowiso commented Oct 28, 2024

To work around this, I'm trying to wrap any math that contains the \\ pattern in \displaylines{ math }.

Of course, there are uses of \\ that should not be put into \displaylines, such as \begin{align}...\end{align} blocks, but you might be able to filter those out.

In any case, the v3 approach for your situation is to use the startup.ready function in your MathJax configuration. For example:

MathJax = {
  startup: {
    ready() {
      MathJax.startup.defaultReady();
      MathJax.startup.document.inputJax[0].preFilters.add(({math}) => {
        if (math.math.match(/\\\\/)) {
          math.math = `\\displaylines{${math.math}}`;
        }
      });
    }
  }
}

is a simple version that does what you ask, but could be made more sophisticated to avoid the environments that use \\ already for line breaking.

Thanks David, this works!

I added one extra check to avoid the wrapping in case of tabular environments, though when I was testing, it did not matter in the rendering of the environment when they were wrapped in \displaylines. For reference, here's my adjustment:

        if (math.math.match(/\\\\/) && !math.math.match(/\\begin\{/)) {
          math.math = `\\displaylines{${math.math}}`;
        }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Code Example Contains an illustrative code example, solution, or work-around v3
Projects
None yet
Development

No branches or pull requests