-
Notifications
You must be signed in to change notification settings - Fork 18
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
\\ macro should be parsed differently in some math environments #40
Comments
Hmmm, I don't completely understand your comment, but I thought I had made it so that whitespace prevented
It seems this behavior is tested here: unified-latex/packages/unified-latex-util-arguments/tests/gobble-single-argument.test.ts Line 475 in 622ab41
So I am not sure where it's going wrong... |
I found the following relevant excerpt in xparse documentation page 4: There is one subtlety here due to the difference in handling by TEX of “control \DeclareDocumentCommand \\ { !s !o } { ... } According to it, |
Good find! #41 fixes this issue. I'll release a new version when the tests pass. |
Fixed issue #40; incorrect signature for \\
I am not sure if the fix is correct. The signature is not globally The current infrastructure doesn't seem to allow signatures to change based on neighboring environment, so I guess it won't be a simple fix. |
Yes, currently macros are defined globally. It's possible to let an environment redefine the macros it uses (see the tikz package), but it's annoying. I think most people don't even know that you can do |
It seems that tikz code is pretty specialized to that case. In general, macros are only available to an enclosing group and IMO it is an essential feature that allows basic encapsulation, but unified-latex currently treats every macro as global. |
That's a good point. Would you mind opening a new issue for per-environment macro overrides? |
Well, I don't have resource to work on it, so I'd rather not "own" the issue. |
Steps to reproduce
Expected behavior
In the first
1 \\ [10pt] 2
line,[10pt]
is treated as an argument for the\\
macro.However, in the second occurrence, [10pt] is rendered directly to the output. Only after removing a whitespace between
\\
and[10pt]
it is treated as an argument for\\
.Thus, the parsed AST should treat two cases differently.
Actual behavior
unified-latex
currently parses [10pt] as an optional argument for\\
in both cases.It seems that this behavior is specific to
gather
environment, because foreqnarray*
,[10pt]
is always treated as an argument for\\
,which seems to be a sensible behavior. I hit this with tex codes having Lie brackets right after a line break.
I'm wondering if there's a central source of truth for such a subtle parsing behavior - where can I find how exactly
gather*
environment modifies it?The text was updated successfully, but these errors were encountered: