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

show math.equation: set align(...) breaks alignment points #3973

Closed
1 task done
EpicEricEE opened this issue Apr 21, 2024 · 8 comments · Fixed by #4094
Closed
1 task done

show math.equation: set align(...) breaks alignment points #3973

EpicEricEE opened this issue Apr 21, 2024 · 8 comments · Fixed by #4094
Labels
bug Something isn't working math Related to math syntax, layout, etc.

Comments

@EpicEricEE
Copy link
Contributor

Description

The alignment set with show math.equation: set align(...) overrides the left-right alternating behavior of alignment points:

$ a + b &= c \
      e &= f + g + h $
Alignment Output
default image
start image
end image

Reproduction URL

No response

Operating system

Web app

Typst version

  • I am using the latest version of Typst
@EpicEricEE EpicEricEE added the bug Something isn't working label Apr 21, 2024
@Leedehai
Copy link
Contributor

Leedehai commented Apr 23, 2024

I'm not sure this is a bug.. 🤔 maybe WAI? Because the code below (added by #936) seems intentional to only use alternator in the _-case:

let mut alternator = LeftRightAlternator::Right;
move || match align {
FixedAlignment::Start => prev_points.next(),
FixedAlignment::End => {
point_widths.next().map(|(point, width)| point - width)
}
_ => point_widths
.next()
.zip(prev_points.next())
.zip(alternator.next())
.map(|(((point, width), prev_point), alternator)| match alternator {
LeftRightAlternator::Left => prev_point,
LeftRightAlternator::Right => point - width,
}),
}

@laurmaedje and @SUPERCILEX (the PR author), thoughts?

@SUPERCILEX
Copy link
Contributor

Yeah, that's how it's supposed to work. If OP's goal to align the whole equation in its outer context, does putting it in a box and aligning that work instead?

@EpicEricEE
Copy link
Contributor Author

This show-set rule is the intended way of setting the "main" alignment of block equations (see #2156, #2157 and on Discord), so I would argue that it's not intended.

@Enivex
Copy link
Collaborator

Enivex commented Apr 23, 2024

Yeah, that's how it's supposed to work. If OP's goal to align the whole equation in its outer context, does putting it in a box and aligning that work instead?

That will break the moment the equation has numbering.

This is almost certainly not intended behavior, and if it is I would question why it is.

@Enivex Enivex added the math Related to math syntax, layout, etc. label Apr 23, 2024
@SUPERCILEX
Copy link
Contributor

I guess does anybody use the feature? We could get rid of it, but I vaguely recall some discussion that led to wanting to be able to change how internal equation alignment worked. For OP's purposes, using left/right instead should get the job done now that I'm rereading this.

@laurmaedje
Copy link
Member

I agree that the current behaviour is unexpected. We should probably just get rid of it.

I vaguely recall some discussion that led to wanting to be able to change how internal equation alignment worked.

Do you happen to be able to still find that?

@SUPERCILEX
Copy link
Contributor

Nope, so feel free to get rid of it. :)

@PgBiel
Copy link
Contributor

PgBiel commented May 9, 2024

I think the main problem here is that alignment in math equations and text alignment are currently treated as two very separate things, so this behavior comes off as surprising. It seems perhaps ideal to remove this for the time being and maybe add some other option to math.equation itself in the future, if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working math Related to math syntax, layout, etc.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants