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

Amscd #2449

Merged
merged 4 commits into from
Dec 18, 2024
Merged

Amscd #2449

merged 4 commits into from
Dec 18, 2024

Conversation

brucemiller
Copy link
Owner

This PR fixes the amscd package to make the horizontal connectors (typically arrows) stretch. Since MathML (currently?) only stretches horizontally the participants in mover/munder (see w3c/mathml-core#270) some extra support (hack) is needed in the MathML postprocessing. But the end result now looks like it should.

@brucemiller brucemiller requested a review from dginev December 18, 2024 17:14
role => 'ARROW', stretchy => 'true', meaning => 'leftrightarrow', width => Dimension('30pt')); });
DefPrimitive('\lx@amscd@equals', sub {
Box("=", undef, undef, T_OTHER('='),
role => 'ARROW', stretchy => 'true', meaning => 'equals', width => Dimension('30pt')); });
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a clarifying question:

What is the intended meaning of an XMTok that has a set positive width (30pt here), with stretchy="true" at the same time?

Does the XMath width act as min-width in this circumstance?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha! Good question! So, the way it gets converted to MathML (wrapped in an mover with a wide mspace, in this PR) allows for the expectation that other table cells might be wider and cause the arrow to stretch even further, so that it would act as a min-width. However, the current MathML-Core apparently only does horizontal stretch within mover/munder, so it would never see those other cells' widths. So, in practice (currently) it would act as the width.

# First, special case hack for stretchy arrows, with specified width
# Stretchiness (currently) only has effect within munder/mover!!!!!
if ($width && (($role || '') eq 'ARROW') && !$unstretchy) { # SPECIAL CASE HACK
$result = ['m:mover', {}, $result, ['m:mspace', { width => $width }]]; }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if a well-named class attribute for this special case won't be useful in the future. Would make it a little clearer for people inspecting the markup, and easy to check when it gets refactored as MathML Core improves.

Maybe <mover class="ltx_math_stretched"> ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The $unstretchy check may not be booleany enough. If we go with strecthy="true" by default, and when explicit, then everything else is false (including invalid values), then:

  my $stretchy_attr = $node->getAttribute('stretchy') || ($parent && $parent->getAttribute('stretchy')) || "true";
  my $unstretchy = $strechy_attr neq "true";

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Somehow I knew you'd suggest that, so why didn't I just head you off by implementing it? But actually, something like \ltx_horizontally_stretched might be even better; I was a little concerned about the code doing something weird with vertically stretching cases. (Alas, no visible distinction in MathML)

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, if a class is going to be used to detect the "special case", then we can drop the test of stretchy completely.

</XMCell>
<XMCell/>
<XMCell align="center">
<XMTok fontsize="160%" name="uparrow" role="ARROW">↑</XMTok>
<XMTok fontsize="160%" name="||" role="VERTBAR">∥</XMTok>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name="||" got me curious, so I checked the DefMath, which indeed uses that name for \|.

DefMathI('\|',        undef, "\x{2225}", role => 'VERTBAR',  name    => '||');

In the TeXbook, I see its definition marked with "vertical line" in Appendix E, p. 420:

\def\|{\leavevmode\hbox{\tt\char‘\|}} % vertical line

Would vertical-lines be a better name in this case?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be, but name is a bit of an orphan: it's somewhere between the content, reversion and meaning; it probably shouldn't even exist at all, but it does get used for various checks.
At some point in the not too distant future, a scan of all uses needs to be analyzed and figure out where to go with it. Perhaps it should end up being part of intent infrastructure? So: Hold onto that thought!

@dginev dginev self-requested a review December 18, 2024 19:06
@brucemiller
Copy link
Owner Author

OK, I added class=ltx_horizontally_stretchy to the arrows, and use that to detect the special case in postprocessing. So take another look.

Copy link
Collaborator

@dginev dginev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even better, LGTM.

@brucemiller brucemiller merged commit 116748f into master Dec 18, 2024
26 checks passed
@brucemiller brucemiller deleted the amscd branch December 18, 2024 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants