refstyle and amsmath

Richard Kimberly Heck rikiheck at gmail.com
Tue Jan 30 17:30:40 UTC 2024


On 1/30/24 12:17, Jürgen Spitzmüller wrote:
> Am Montag, dem 29.01.2024 um 15:00 +0100 schrieb Kees Zeelenberg:
>> Some time ago there was a discussion on the list about refstyle in
>> combination with amsmath, leading to error messages from refstyle. It
>> appears refstyle is now loaded after amsmath, but this now leads to
>> messages like “LaTeX Warning: Reference `ab' on page 1 undefined on
>> input line 39” from the enclosed LyX file ‘testref.lyx’.
> The loading order has not been changed, and it also doesn't matter (as
> a view into refstyle.sty reveals). The warning is also in LyX 2.3.x,
> although it is less prominent (the heightening of prominence was done
> in purpose for 2.4, since you will want to be informed about broken
> references).
>
>> It seems that this is related to the LaTeX line
>> “\AtBeginDocument{\providecommand\eqref[1]{\ref{eq:#1}}}”, which is
>> added by LyX in ‘testref.tex’. This line does not have any effect, so
>> that e.g. \eqref{ab}  is interpreted as \ref{ab}  instead of
>> \ref{eq:ab}.
> This is by design as well. This definition gets only active in case
> \eqref is undefined, hence \providecommand.
>
>> Replacing this line with
>> \AtBeginDocument{\DeclareRobustCommand{\eqref}[1]{\textup{\tagform@{\
>> ref{eq:#1}}}}} (as in amsmath), the LaTeX file ‘testref_robust.tex’
>> compiles without problems.
> Yes, but this is not the right fix as it will break the refstyle
> integration with equation references.
>
> The problem here is that refstyle attempts to overwrite and integrate
> amsmath's \eqref definition into its own \eqref definition. This does
> not work anymore since \eqref has been made robust in the 2022-06-01
> release of amsmath [1], and the command copying and redefinition
> refstyle used (via \let) does not work with robust commands.
> \NewCommandCopy needs to be used instead of \let.
>
> Ultimately, this needs to be fixed in refstyle. I reported this to the
> maintainer in March 2023 and even sent a patch [2] but never got a
> response. It seems the package is factually unmaintained.
>
> We can check for the respective amsmath version and patch into refstyle
> ourselves in LyX.

I guess we need to do something like that for 2.4?

Riki




More information about the lyx-users mailing list