Skip to content

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

@woody-li

Description

@woody-li

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.

Activity

dpvc

dpvc commented on Oct 2, 2019

@dpvc
Member

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

woody-li commented on Oct 3, 2019

@woody-li
Author

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

dpvc commented on Oct 4, 2019

@dpvc
Member

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

dpvc commented on Oct 4, 2019

@dpvc
Member

In the meantime, you can do something like

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

to get multiple lines

woody-li

woody-li commented on Oct 4, 2019

@woody-li
Author

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

SeanFlemingMathsPathway commented on Oct 9, 2019

@SeanFlemingMathsPathway

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

T-Kuhn commented on Feb 4, 2020

@T-Kuhn

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

dpvc commented on Feb 4, 2020

@dpvc
Member

@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

dpvc commented on Feb 4, 2020

@dpvc
Member

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

transferred this issue frommathjax/MathJax-srcon Feb 4, 2020
T-Kuhn

T-Kuhn commented on Feb 5, 2020

@T-Kuhn

@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

dpvc commented on Feb 5, 2020

@dpvc
Member

@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.

92 remaining items

CaneMandarinesco

CaneMandarinesco commented on Jan 28, 2024

@CaneMandarinesco

2024 and still no fix?
immagine

dpvc

dpvc commented on Jan 28, 2024

@dpvc
Member

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

JWock82 commented on Apr 7, 2024

@JWock82

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

Nambers

Nambers commented on Oct 20, 2024

@Nambers

Any update on releasing? It been some months

sowiso

sowiso commented on Oct 25, 2024

@sowiso

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

dpvc commented on Oct 27, 2024

@dpvc
Member

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

dpvc commented on Oct 27, 2024

@dpvc
Member

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.

added
Code ExampleContains an illustrative code example, solution, or work-around
on Oct 27, 2024
sowiso

sowiso commented on Oct 28, 2024

@sowiso

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Code ExampleContains an illustrative code example, solution, or work-aroundv3

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @cdwilson@jmhammond@jasongrout@pkra@dpvc

        Issue actions

          The line break(\\) is not work · Issue #2312 · mathjax/MathJax