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

min-widthis not changed for the formulas \begin{equation}...\end{equation} #2280

Closed
OlgaRedozubova opened this issue Jan 2, 2020 · 4 comments
Labels
Expected Behavior This is how MathJax works v3

Comments

@OlgaRedozubova
Copy link

For \begin{equation}...\end{equation} the size of the container is not changed regardless of the value containerWidth

\begin{equation}
\begin{aligned}
\mathbb{P}\left[X_{n+1}=i_{n+1} | B\right]=& \mathbb{P}\left[X_{n+1}=i_{n+1} | B \cap A_{1}\right] \mathbb{P}\left[A_{1} | B\right] \\ &+\mathbb{P}\left[X_{n+1}=i_{n+1} | B \cap A_{2}\right] \mathbb{P}\left[A_{2} | B\right] \\=& \mathbb{P}\left[X_{n+1}=i_{n+1} | B \cap\left\{X_{n}=i_{n}\right\}\right] \mathbb{P}\left[X_{n}=i_{n} | B\right] \\ &+\mathbb{P}\left[X_{n+1}=i_{n+1} | B \cap\left\{X_{n}=-i_{n}\right\}\right] \mathbb{P}\left[X_{n}=-i_{n} | B\right] 
\end{aligned}
\end{equation}

But for this formula everything works

\begin{aligned}
\mathbb{P}\left[X_{n+1}=i_{n+1} | B\right]=& \mathbb{P}\left[X_{n+1}=i_{n+1} | B \cap A_{1}\right] \mathbb{P}\left[A_{1} | B\right] \\ &+\mathbb{P}\left[X_{n+1}=i_{n+1} | B \cap A_{2}\right] \mathbb{P}\left[A_{2} | B\right] \\=& \mathbb{P}\left[X_{n+1}=i_{n+1} | B \cap\left\{X_{n}=i_{n}\right\}\right] \mathbb{P}\left[X_{n}=i_{n} | B\right] \\ &+\mathbb{P}\left[X_{n+1}=i_{n+1} | B \cap\left\{X_{n}=-i_{n}\right\}\right] \mathbb{P}\left[X_{n}=-i_{n} | B\right] 
\end{aligned}

screenshot-localhost_3000-2020 01 02-12_04_27 (1)

I have also tried to set docTeX.options.OutputJax.minwidth = ..
But I see that this value is re attributed https://github.com/mathjax/MathJax-src/blob/master/ts/output/svg.ts#L265

Please, tell me how I can change the container's width in this case.

@dpvc
Copy link
Member

dpvc commented Jan 2, 2020

First, containerWidth is supposed to be the width of the element that contains the math and is used for line-breaking purposes. But version 3 doesn't yet implement line breaking, so currently containerWdith is essentially unused in version 3. So changing that value won't do anything at the moment (it will once line breaking is implemented).

Second, the minwidth value is not something you can set yourself, as it is used and maintained internally for computing the minimum width needed for a table. You don't get to set that yourself; it is based on the contents of the table and the labels for the table.

The min-width value that you see in the styles for the sag element is correct, and required for proper layout. It is used where there is a numbered two in a table, as there should be in your case; it is hard to tell, since the right-hand edge of the SVG is covered by the DOM display, but with the equation environment, it should be numbered automatically if you have tags: 'ams' in your tex configuration block (you haven't included your configuration, so that is not clear).

The reason for this is to prevent the equation labels from overlapping the equation itself. to do that, MathJax uses min-width to prevent the SVG element from getting soo small that the number and equation overlap. Because the equation is centered, that means that MathJax must reserve the same amount of space on both sides, and so the space that is reserved for the SVG is the width of the equation plus twice the width of the label and the space between the equation and the label. That is the unfortunate consequence of centered equations.

Your second expression is not numbered, and so it doesn't need the min-width setting of numbered equations. The SVG as a whole is centered in the mjx-container element, rather than using a full-width SVG that has floating sub-SVG elements inside it that are needed for numbered equations, and the width of the SVG is fixed in that case, so no min-width is needed.

Finally, that aligned is not intended as a top-level environment (that would not be allowed in actual LaTeX), so it should be used inside \begin{equation*}...\end{equation*} or some other display-style delimiters.

@dpvc
Copy link
Member

dpvc commented Jan 2, 2020

I am transferring this to the mathjax/MathJax repository, where all issues should be reported.

@dpvc dpvc transferred this issue from mathjax/MathJax-src Jan 2, 2020
@dpvc dpvc added the Expected Behavior This is how MathJax works label Jan 2, 2020
@OlgaRedozubova
Copy link
Author

Thank you so much for your reply.

I use the tags: "ams" option. In the previous screenshot, the numbering is not visible since it is hiding.
I want to clarify in the example below, it turns out that the min-width for the formulas \begin {equation} ... \end {equation} exceeds the width of the container
because of this, part of the formula is hidden.
Is there a way to reduce the min-width for the formulas \begin{equation} ... \end{equation}?

ezgif com-video-to-gif (55)

\begin{equation}
\begin{aligned}
\mathbb{P}\left[X_{n+1}=i_{n+1} | B\right]=& \mathbb{P}\left[X_{n+1}=i_{n+1} | B \cap A_{1}\right] \mathbb{P}\left[A_{1} | B\right] \\ &+\mathbb{P}\left[X_{n+1}=i_{n+1} | B \cap A_{2}\right] \mathbb{P}\left[A_{2} | B\right] \\=& \mathbb{P}\left[X_{n+1}=i_{n+1} | B \cap\left\{X_{n}=i_{n}\right\}\right] \mathbb{P}\left[X_{n}=i_{n} | B\right] \\ &+\mathbb{P}\left[X_{n+1}=i_{n+1} | B \cap\left\{X_{n}=-i_{n}\right\}\right] \mathbb{P}\left[X_{n}=-i_{n} | B\right] 
\end{aligned}
\end{equation}
\begin{equation*}
\begin{aligned}
\mathbb{P}\left[X_{n+1}=i_{n+1} | B\right]=& \mathbb{P}\left[X_{n+1}=i_{n+1} | B \cap A_{1}\right] \mathbb{P}\left[A_{1} | B\right] \\ &+\mathbb{P}\left[X_{n+1}=i_{n+1} | B \cap A_{2}\right] \mathbb{P}\left[A_{2} | B\right] \\=& \mathbb{P}\left[X_{n+1}=i_{n+1} | B \cap\left\{X_{n}=i_{n}\right\}\right] \mathbb{P}\left[X_{n}=i_{n} | B\right] \\ &+\mathbb{P}\left[X_{n+1}=i_{n+1} | B \cap\left\{X_{n}=-i_{n}\right\}\right] \mathbb{P}\left[X_{n}=-i_{n} | B\right] 
\end{aligned}
\end{equation*}

@dpvc
Copy link
Member

dpvc commented Jan 2, 2020

Equations that are too wide for the container do extend past the right-hand side of the container. Automatic line breaking can help in some cases but (as mentioned) that is not yet ported to version 3, and it is not very effective with tables (which is how the aligned environment is implemented), so it would not be very helpful here even so.

As I mentioned, the minimum width is the actual minimum required size for the expression and its label (when the equation is centered), and it can not be reduced without damaging the rendering. The second example you give does not contradict that because it has no label. If the container we a bit less wide, that one would extend beyond the right-hand side as well.

The only option to get a reduced is to reduce the size of the font surrounding the expression. You could do that by adding a span or div that has CSS that reduces the font size. E.g.,

<div style="font-size: 90%">
\begin{equation}
\begin{aligned}
\mathbb{P}\left[X_{n+1}=i_{n+1} | B\right]=& \mathbb{P}\left[X_{n+1}=i_{n+1} | B \cap A_{1}\right] \mathbb{P}\left[A_{1} | B\right] \\ &+\mathbb{P}\left[X_{n+1}=i_{n+1} | B \cap A_{2}\right] \mathbb{P}\left[A_{2} | B\right] \\=& \mathbb{P}\left[X_{n+1}=i_{n+1} | B \cap\left\{X_{n}=i_{n}\right\}\right] \mathbb{P}\left[X_{n}=i_{n} | B\right] \\ &+\mathbb{P}\left[X_{n+1}=i_{n+1} | B \cap\left\{X_{n}=-i_{n}\right\}\right] \mathbb{P}\left[X_{n}=-i_{n} | B\right] 
\end{aligned}
\end{equation}
</div>

but this has to be done by hand (MathJax doesn't have an automatic way to do that).

Alternatively, you could arrange for the div to have overflow: scroll so that it can be scrolled to the right or left to expose the rest of the equation.

Just to reiterate, the result you are experiencing is the correct behavior for MathJax.

@dpvc dpvc added the v3 label Feb 19, 2020
@dpvc dpvc closed this as completed Feb 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Expected Behavior This is how MathJax works v3
Projects
None yet
Development

No branches or pull requests

2 participants