回想録のサブインデックスで偶数ページに表を強制すると、amsmath の \numberwithin が混乱する

回想録のサブインデックスで偶数ページに表を強制すると、amsmath の \numberwithin が混乱する

私が表が偶数ページに配置されるようにする Schweinebacke のソリューションmemoirの環境内でをsubappendicesと組み合わせると、 は機能しなくなります。つまり、テーブルは "1.A.1" ではなく "1.1.1" として番号付けされます。amsmath\numberwithin\numberwithin

どうすれば修正できますか?

\documentclass{memoir}
\usepackage{afterpage}
\usepackage{amsmath}
\newcommand{\atevenpage}[1]{%
  \afterpage{\clearpage%
    \ifodd\value{page}%
      \atevenpage{#1}%
    \else%
      #1%
    \fi%
  }%
}
\usepackage{filecontents}
\begin{filecontents*}{my_input.tex}
  \begin{table}[p]
    \caption{A table}
    \begin{tabular}{lrr}
      & A & B \\
      First row & 123 & 456 \\
      Second row & 123 & 456 \\
    \end{tabular}
  \end{table}
\end{filecontents*}
\begin{document}
  \chapter{A chapter}
  \begin{subappendices}
    \numberwithin{table}{section}
    \section{An appendix}
    \atevenpage{\input{my_input}}
  \end{subappendices}
\end{document}

答え1

長いコメントです。

これを前文に追加してみてください

\AddToHook{env/subappendices/begin}{\typeout{begin subapp}}
\AddToHook{env/subappendices/end}{\typeout{end subapp}}
\AddToHook{env/table/begin}{\typeout{begin table}}
\AddToHook{env/table/end}{\typeout{end table}}

ログを見ると、テーブルの遅延により、テーブルの実行時にサブ付録がすでに終了していることがわかります。は\numberwithin{table}{section}ローカル定義なので、\end{subappendices}

関連情報