1 点訂正します.
\getpagewiselinenumber@XR の定義の先頭と末尾((*) のところ)に括弧({,})を追加してください.
\def\getpagewiselinenumber@XR#1#2{{%%% (*)
\let\@saved@NumberedPageCache\NumberedPageCache
\let\@saved@LN@Pfirst\LN@Pfirst
\global\expandafter\let\expandafter\NumberedPageCache
\csname #1NumberedPageCache\endcsname
\global\expandafter\let\expandafter\LN@Pfirst
\csname #1LN@Pfirst\endcsname
\expandafter\ifx\csname c@linenumber\endcsname\relax
\newcount\c@linenumber
\fi
\expandafter\ifx\csname c@linenumber\endcsname\relax
\newcount\c@linenumber
\fi
\c@linenumber #2\relax
\testNumberedPage
\expandafter\global\expandafter\let
\csname #1NumberedPageCache\endcsname\NumberedPageCache
\global\let\NumberedPageCache\@saved@NumberedPageCache
\global\let\LN@Pfirst\@saved@LN@Pfirst
\thelinenumber}}%%% (*)
\getpagewiselinenumber@XR の定義の先頭と末尾((*) のところ)に括弧({,})を追加してください.
\def\getpagewiselinenumber@XR#1#2{{%%% (*)
\let\@saved@NumberedPageCache\NumberedPageCache
\let\@saved@LN@Pfirst\LN@Pfirst
\global\expandafter\let\expandafter\NumberedPageCache
\csname #1NumberedPageCache\endcsname
\global\expandafter\let\expandafter\LN@Pfirst
\csname #1LN@Pfirst\endcsname
\expandafter\ifx\csname c@linenumber\endcsname\relax
\newcount\c@linenumber
\fi
\expandafter\ifx\csname c@linenumber\endcsname\relax
\newcount\c@linenumber
\fi
\c@linenumber #2\relax
\testNumberedPage
\expandafter\global\expandafter\let
\csname #1NumberedPageCache\endcsname\NumberedPageCache
\global\let\NumberedPageCache\@saved@NumberedPageCache
\global\let\LN@Pfirst\@saved@LN@Pfirst
\thelinenumber}}%%% (*)