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

Toggle old alignment behavior for equations #2370

Closed
fredrik-johansson opened this issue Mar 6, 2016 · 8 comments
Closed

Toggle old alignment behavior for equations #2370

fredrik-johansson opened this issue Mar 6, 2016 · 8 comments
Milestone

Comments

@fredrik-johansson
Copy link

Previously, if you put two equations inside one math block

.. math ::

    A

    B

both would show up centered. Due to recent changes in sphinx (which puts them in an align environment), they now render right-aligned. I can get back to two centered equations using

.. math ::

    A

.. math ::

    B

but this is less convenient. Is there any way to restore the old behavior?

@fredrik-johansson
Copy link
Author

BTW, the workaround to get two centered equations is not perfect. Although it gives similar output to the old behavior with HTML+MathJax, it creates an extra vertical space in latexpdf output.

@tk0miya
Copy link
Member

tk0miya commented Mar 25, 2016

Indeed. It comes from #2254. I reproduce this with following code:

Single equation in single math directive:

.. math ::

    A

Multiple equations in single math directive:

.. math ::

    A

    B

Multiple equations in multiple math directives:

.. math ::

    A

.. math ::

    B

Indeed, the equations are slightly misaligned.
2016-03-24 21 55 02

@jfbu
Copy link
Contributor

jfbu commented Mar 25, 2016

Perhaps there is some more up-to-date info but I have already found this : http://tex.stackexchange.com/a/8142/4686, which says

for some reason, a one-line "aligned" is not properly centered. this appears to be a bug, and i am entering it as such in the amsmath bugs list.

Anyway, things are produced like

\begin{align*}\begin{aligned}
\begin{split}A\end{split}\\
\begin{split}B\end{split}\end{aligned}\end{align*}

and I am not sure about split inside aligned inside align*. The split environment is designed for use in full-width environments align, gather, or equation. The amsmath documentation doesn't have a single example of split inside aligned. Where would the & and \\ which split uses come from ?

@jfbu
Copy link
Contributor

jfbu commented Mar 25, 2016

I obtain centered results with

Single equation in single math directive:
\begin{align*}\!\begin{aligned}
\begin{split}\boxed{A}\end{split}\\\end{aligned}\end{align*}
Multiple equations in single math directive:
\begin{align*}\!\begin{aligned}
\begin{split}\boxed{A}\end{split}\\
\begin{split}\boxed{B}\end{split}\\\end{aligned}\end{align*}

\noindent\rule{.5\linewidth}{3pt}%
\kern-.2pt 
\smash{\rule[-5cm]{.4pt}{10cm}}%
\kern-.2pt 
\rule{.5\linewidth}{6pt}

Multiple equations in multiple math directives:
\begin{align*}\!\begin{aligned}
\begin{split}\boxed{A}\end{split}\\\end{aligned}\end{align*}\begin{align*}\begin{aligned}
\begin{split}\boxed{B}\end{split}\\\end{aligned}\end{align*}

capture d ecran 2016-03-25 a 17 16 08

The recipe appears to be to use \!\begin{aligned}.....\\\end{aligned}, hence an extra \! before \begin{aligned} and an extra \\ before \end{aligned}. Not tested apart from the above.

(and I still don't understand the reason for split)

@jfbu
Copy link
Contributor

jfbu commented Mar 25, 2016

In my previous comment notice that the bottom boxed B is not centered but I forgot the \! before \begin{aligned} for the last one. If one adds it, the bottom boxed B is centered.

@tk0miya
Copy link
Member

tk0miya commented Mar 28, 2016

Thank you for comment. It looks very nice!

The aligned also comes from #2254 . It is used to wrap whole of equations and give only one equation-number label.
But I don't know why aligned and split is used at same time. I did not care that.
@xuhdev Do you remember the reason?

@xuhdev
Copy link
Contributor

xuhdev commented Mar 28, 2016

I think it's OK to remove split inside aligned. I don't remember the exact reason, but I feel like that I added split inside aligned for semantic purpose only: split splits single equations. If it causes any issues, we can remove it.

According to @jfbu 's comments, we should use different environments for single equations (split inside equation) and multiple equations (align).

@tk0miya
Copy link
Member

tk0miya commented Apr 14, 2016

I fixed this at 39396a4 and 3206ccb.

Finally I use equation and split for single equation and align and aligned for multiple equations.
If you find another problem, please let me know.

Thanks!

@tk0miya tk0miya closed this as completed Apr 14, 2016
@tk0miya tk0miya added this to the 1.4.2 milestone Apr 14, 2016
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants