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

Fix #317 equation lables #383

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

Fix #317 equation lables #383

wants to merge 8 commits into from

Conversation

Blendify
Copy link
Member

@Blendify Blendify commented Mar 8, 2017

Fix #301 this fixes this issue and hides the headerlink until hovering however, the header link is not showing up when it is set to float to the right. Any help on fixing this would be appreciated.

@agjohnson
Copy link
Collaborator

Can you provide examples of before and after this change? It helps more than looking at the style rules.

@agjohnson agjohnson added the Needed: more information A reply from issue author is required label Mar 8, 2017
@Blendify
Copy link
Member Author

Blendify commented Mar 8, 2017

Before:
mathold

After:
new math

@agjohnson
Copy link
Collaborator

I like the placement of the footnote better, that makes much more sense :) When I get a chance I can try to replicate the issue. I'll assign myself, but anyone else feel free to chime in here.

@agjohnson agjohnson self-assigned this Mar 9, 2017
@Blendify Blendify changed the title Equation lables Fix #317 equation lables Mar 15, 2017
@ibell
Copy link

ibell commented Mar 19, 2017

This is a big issue for me with this theme, and I'm looking forward to this PR getting merged.

@Blendify Blendify added this to the v0.2.6 milestone Jun 18, 2017
@Blendify Blendify modified the milestones: v0.2.5, v0.2.6 Dec 3, 2017
@hagenw
Copy link

hagenw commented Dec 3, 2017

The header link is not showing up during mouse hover, because the .MathJax_Display element covers the number. If you set its width from 100% to a smaller value like 90% its working. But then the float is no longer working as expected for small screens and long equations as the number gets covered by the equation.

I implemented a version placing the equation number to the right without float, but with absolute positioning which has the advantage that we can then vertically align the number.
mathjax
A full example can be found at http://sfstoolbox.org/en/mathjax/nfchoa/.

In addition to the number placement, I added overflow scrolling to solve the problem with small screens.
mathjax_small

Finally, I replaced the header link symbol by the symbol used by RTD similar to the hack in the RTD headerlink section.
mathjax_hover

Here is the full CSS:

div.math {
    position: relative;
    padding-right: 2.5em;
}
.eqno {
    height: 100%;
    position: absolute;
    right: 0;
    padding-left: 5px;
    padding-bottom: 5px;
    /* Fix for mouse over in Firefox */
    padding-right: 1px;
}
.eqno:before {
    /* Force vertical alignment of number */
    display: inline-block;
    height: 100%;
    vertical-align: middle;
    content: "";
}
.eqno .headerlink {
    display: none;
    visibility: hidden;
    font-size: 14px;
    padding-left: .3em;
}
.eqno:hover .headerlink {
    display: inline-block;
    visibility: hidden;
    margin-right: -1.05em;
}
.eqno .headerlink:after {
    visibility: visible;
    content: "\f0c1";
    font-family: FontAwesome;
    display: inline-block;
    margin-left: -.9em;
}
/* Make responsive */
.MathJax_Display {
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
}

jahn referenced this pull request in jahn/altMITgcm Dec 19, 2017
@hagenw
Copy link

hagenw commented Dec 19, 2017

Updated the css example to include a fix for Firefox, see jahn/MITgcm@3479d99 for an alternative solution.

@jahn
Copy link

jahn commented Jan 6, 2018

Alternatively, one can tie visibility to the entire .math element. This also seems more logical. The following complete example works for me:

.eqno {
    margin-left: 5px;
    float: right;
}
.math .headerlink {
    display: none;
    visibility: hidden;
}
.math:hover .headerlink {
    display: inline-block;
    visibility: visible;
    margin-right: -0.7em;
}

Note that the link symbol is moved out into the margin. Otherwise, it will also be covered by .MathJax_Display and not clickable.

@hagenw
Copy link

hagenw commented Jan 7, 2018

This is indeed a good alternative and more in line with the behavior of the section permalinks.

I decided against it as I don't see a possibility to influence the vertical alignment of the equation number (it is always at the right top of the equation). The vertical alignment in my example is also still not perfect as it is not the same as in LaTeX, but it looks already ok.

What is good about using float is that the equation number moves above the equation if we are running out of space.

Another difference is that the equation link becomes visible in your case as soon as the mouse hovers the equation. This is in line with the header links and maybe a user would expect it. But I'm still not sure if it is the best behavior for a page with lots of equations. I think it produces less distraction if the link symbol only pops up if you hover the equation number. On the other hand it is not obvious to a user and she might not be able to detect it herself.

@jahn
Copy link

jahn commented Jan 7, 2018

Yes, I like the vertical placement in your solution better (but baseline alignment would be even better). What I didn't like is that one has to hard-code the maximum width of the equation number and that all equations move slightly off-center horizontally (because of that hard-coded width), regardless of whether they have an equation number or not. One also looses a fair amount of space on small screens if one has to set a large maximum width for equation numbers.

It would be great if one could have better vertical alignment without having to reserve space for equation numbers.

@agjohnson agjohnson modified the milestones: v0.4.0, 0.5 Jun 7, 2018
@nosarthur
Copy link

I still see this problem in my sphinx document (compiled with sphinx-rtd-theme-0.4.0). What is the earliest release to include this fix?

@borisalmonacid
Copy link

its' ok ?

@agjohnson agjohnson modified the milestones: 0.5, 0.6 May 7, 2020
@agjohnson
Copy link
Collaborator

Apologies, I haven't had time to look into this one more -- the mathjax stuff is new to me. Does html5 writer or theme release 0.5.0rc1 alter any of this?

@ka-bo
Copy link

ka-bo commented May 8, 2020

Thanks. I just tried sphinx-rtd-theme release 0.5.0rc1 and the problem persists.

@gasse gasse mentioned this pull request Aug 3, 2020
1 task
dmey added a commit to dmey/synthia that referenced this pull request Sep 22, 2020
@agjohnson agjohnson modified the milestones: 1.1, 1.0 Mar 31, 2021
@agjohnson agjohnson added the Bug A bug label Mar 31, 2021
@Blendify Blendify modified the milestones: 1.0, 1.1 Apr 1, 2021
fritzt pushed a commit to CESM-GC/CTSM that referenced this pull request May 19, 2021
This comes from altMITgcm/MITgcm#12, which I
found in a link from
readthedocs/sphinx_rtd_theme#383.

This right-aligns the equation numbers, and only makes the link image
visible if your mouse is hovering above a given equation.
@benjaoming benjaoming requested a review from a team as a code owner August 26, 2022 18:22
@benjaoming
Copy link
Contributor

This PR is still building and the changes still show up nicely.

  1. The CSS additions would have to be reworked for our SASS source
  2. Then tested
  3. We would probably also want to note something in changelog.rst

@benjaoming benjaoming modified the milestones: 1.1, 2.0 Aug 26, 2022
@eebasso
Copy link

eebasso commented Jan 17, 2024

I think I have found a simple solution as described here: #301 (comment)

The corresponding additions to the _theme_mathjax.sass file would presumably be:

span.eqno
  float: right

  a.headerlink
    position: relative
    z-index: 1

It's possible that a.headerlink should be replaced with just .headerlink. Not sure which is better, but both work as far as I can tell based on my testing.

I think the key here is z-index, which makes the headerlink appear above the displayed equation as opposed to being hidden by it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug Needed: more information A reply from issue author is required
Projects
None yet
Development

Successfully merging this pull request may close these issues.

equation number is not aligned to right