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

Unexpected WORD_REPEAT_RULE on big multiline formulas with aligned #83

Closed
petRUShka opened this issue Oct 19, 2020 · 7 comments
Closed
Labels
question Further information is requested

Comments

@petRUShka
Copy link

I have a latex-file with math formulas

For example I have equation:

\begin{equation}
  \begin{aligned}
    f_{13}(x, z) = & x^{3}+ \frac{1}{12} \left(-24 z^{4} + 72 z^{3} - 70 z^{2} + 112 z - 76\right) x^{2} + \\
 & +\frac{1}{11} \left(2877 z^{4} - 9184 z^{3} + 13080 z^{2} - 23436 z + 24318\right) x + \\
 & +\frac{1}{4} \left( 10224 z^{4} - 31451 z^{3} + 46509 z^{2} - 83811 z + 80129 \right).
  \end{aligned}
\end{equation}

and yalafi yields WORD_REPEAT_RULE on this line:

=== my_file.tex ===
28.) Line 547, column 5, Rule ID: WORD_REPEAT_RULE
Message: Возможная опечатка: повтор слова
Suggestion: U-U-U
...ветствует B-B-B, и этим значениям отвечает   U-U-U U-U-U     plus V-V-V     plus W-W-W.  Разложение э...
                                                ^^^^^^^^^^^
@petRUShka petRUShka changed the title Unexpected WORD_REPEAT_RULE on big formulas Unexpected WORD_REPEAT_RULE on big multiline formulas with aligned Oct 19, 2020
@petRUShka
Copy link
Author

I guess the reason is aligned. All these repeats I found only on formulas with aligned.

@matze-dd
Copy link
Collaborator

Thanks for observing this. You are the first who comments on the equation parsing. :)

My assumption is as follows. In order to shift the '+' operators on the second and third line to the right, you write = & on the first line and then & + on the others. I'm not a real expert in using amsmath, so I only can say how I do it. The rules for equation parsing (see here) are designed according to my habits. They are like this.

\begin{align}
a &= b \\
  &\quad + c.
\end{align}

I have used the pure yalafi filter on your example, changed to this style (still with the nested aligned environment). The result is

  V-V-V  equal W-W-W
     plus X-X-X
     plus Y-Y-Y.

A minor remark: you say '+' at the end of the line and repeat it at the beginning of the next one. Is this intentional?

@petRUShka
Copy link
Author

I think both ways of using aligned and & can be used. According to my understanding & is just mark where latex should align. So it isn't restricted to be left or right of = or any other sign.

I intentionally place + at the end and at the beginning of lines. I want to empathize that this is one line just splitted to several in order to fit the page width.

Do we really need to have several lines after YaLafi parsing from one equation? Does it really help to perform proper gramma check?

@matze-dd
Copy link
Collaborator

I think both ways of using aligned and & can be used. According to my understanding & is just mark where latex should align. So it isn't restricted to be left or right of = or any other sign.

Yes, agreed. I just took my style from examples in the amsmath documentation.

Do we really need to have several lines after YaLafi parsing from one equation? Does it really help to perform proper gramma check?

I used it in my documents to find punctuation problems. For instance, if you have two equations in one align block, then there should be a comma after the first equation. See the section in README.

Was always wondering whether this might be too sophisticated for other people. A simpler version that only extracts trailing punctuation is here. At least in German, it is really helpful, as it helps LT to check whether a sentence is properly terminated before starting the next one.

One could provide an option for yalafi to turn on this simpler behaviour for displayed equations. This should insert rotating replacements like V-V-V with appended extracted trailing punctuation.

@petRUShka
Copy link
Author

It's not clear for me. Is it issue what I've found or it's normal behavior?

By the way, look at the output:

...ветствует B-B-B, и этим значениям отвечает   U-U-U U-U-U     plus V-V-V     plus W-W-W.  Разложение э...

it contains U-U-U plus V-V-V (English version of +) and not U-U-U плюс V-V-V (Russian version of +).

@matze-dd
Copy link
Collaborator

It's not clear for me. Is it issue what I've found or it's normal behavior?

It's the currently expected behaviour. I agree with you that the detailed equation parsing may be a bit overdone, as it is based on my personal style for displayed equations. What do you think of the yalafi / yalafi.shell option proposed above that will condense the whole displayed equation into one single replacement like V-V-V, with added punctuation if present?

You can temporarily fix the current status with the hack described here. If you write

\newcommand{\LTadd}[1]{}

in your document preamble and

\begin{equation}
  \begin{aligned}
    f_{13}(x, z) = & \LTadd{=} x^{3}+ \frac{1}{12} \left(-24 z^{4} + 72 z^{3} - 70 z^{2} + 112 z - 76\right) x^{2} + \\
...

then this should suppress the warning. While LeTeX ignores the argument of \LTadd, yalafi includes it during equation parsing.

By the way, look at the output: ...
it contains U-U-U plus V-V-V (English version of +) and not U-U-U плюс V-V-V (Russian version of +).

Yes, the base yalafi filter does not yet support '--lang ru', so it takes 'en' as default. I'll open a new issue for that.

@matze-dd matze-dd added the question Further information is requested label Oct 26, 2020
@matze-dd
Copy link
Collaborator

The problems are now captured by issues #84 and #85.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants