beamer の数式ラベルが二重に登録される

beamer の数式ラベルが二重に登録される

- Toshio Otaguro の投稿
返信数: 4

Beamer を使い始めた初心者なのですが,数式にラベルを付けるとそのラベルがダブって登録されて警告が出ます.出力は期待通りに出るのですが,気持ちが悪いので警告を消す方法はないでしょうか?以下再現ソースです.

\documentclass[unicode,xcolor={svgnames},%
    hyperref={colorlinks,citecolor=Red,linkcolor=Red,urlcolor=Blue}]{beamer}
    \usetheme{Copenhagen}
    \usefonttheme{professionalfonts}

\usepackage[haranoaji,no-math,deluxe]{luatexja-preset}
    \renewcommand{\kanjifamilydefault}{\gtdefault}
\usepackage[TU]{fontenc}
\usepackage{amsmath,amssymb}

\begin{document}
\begin{frame}{数式ラベルの例}
    以下は有名な二次方程式の解の公式です:
    \begin{equation}\label{eqn:quadratic_formula}
        x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}
    \end{equation}
    式\eqref{eqn:quadratic_formula}は二次方程式の解を表します。
\end{frame}
\end{document}
 
これを lualatex で2回コンパイルするのですが,毎回
warning  (pdf backend): ignoring duplicate destination with the name 'eqn:quadratic_formula'
と警告が出ます.snm ファイルにはこのラベルがダブって登録されています.
\beamer@slide {eqn:quadratic_formula}{1}
\beamer@slide {eqn:quadratic_formula}{1}
元になっているはずの aux ファイルの該当部分は以下の通りです.
\@writefile{snm}{\beamer@slide {eqn:quadratic_formula}{1}}
\newlabel{eqn:quadratic_formula}{{1}{1}{}{eqn:quadratic_formula}{}}
\@writefile{snm}{\beamer@slide {eqn:quadratic_formula}{1}}
 
\documentclass で beamer を読み込むときの hyperref のオプションを外しても同じです.また,図や表にラベルを付けてもこのようなことは起こりません.
タグ:
Toshio Otaguro への返信

Re: beamer の数式ラベルが二重に登録される

- 和田 勇 の投稿

途中経過です。

TL2024 の環境と 2025/3/11 にインストールしたままのTL2025 だと報告された事象は発生しませんでした。

以下は 2025/3/11 にインストールしたままのTL2025 とそれを tlmgr update --self --all した 後のものの .log を比較し、報告の警告メッセージが表示されている部分です。

      -{/opt/texlive/2025/texmf-var/fonts/map/pdftex/updmap/pdftex.map}]
      +{/opt/texlive/2025/texmf-var/fonts/map/pdftex/updmap/pdftex.map}
      +warning  (pdf backend): ignoring duplicate destination with the name 'eqn:quadratic_formula'
      +]

それぞれで処理した際の .log と、それらの差分を .zip でまとめたものを添付します。

2025-07-23-3978.log.diff を参考に 2025/4 以降の更新されたファイルをこれから調べようとおもいますが、 並行して調査していただけると助かります。

ファイル名  記事
2025-07-23-3978.log.diff  下二つの差分(余分な差分は省いてあります)
auto-before/2025-07-23-3978.log  今年春にインストールしたままの TL2025 で処理したもの
auto/2025-07-23-3978.log  上記に tlmgr update --self --all でアップデートしたもの
和田 勇 への返信

Re: beamer の数式ラベルが二重に登録される

- Toshio Otaguro の投稿

和田様,

詳しく調べてくださり大変ありがとうございます.ログファイルを見た限りは(私も見てはいたのですが),目立って怪しい所は無いように思います.Beamer そのものや依存するパッケージもアップデートされており,その中身にまで立ち入ることは私には出来ないのですが.お時間に余裕あればで結構ですので,引き続きよろしくお願いいたします.

和田 勇 への返信

Re: beamer の数式ラベルが二重に登録される

- Toshio Otaguro の投稿
あまりに暑いので,老人は部屋に引きこもって Gemini と会話していたところ,次のような解決策が見つかりました.ちなみに Copilot ではこの解にはたどり着きませんでした.再現ソースは以下のように切り詰めています.

\documentclass{beamer}
\begin{document}
\begin{frame}{label to formula}
The solutions of a quadratic equation are,
\begin{equation}{eqn:quadratic_formula}
x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}.
\end{equation}
\end{frame}
\end{document}

これだと,
warning (pdf backend): ignoring duplicate destination with the name 'eqn:quadratic_formula'
と警告が出ます.

Gemini によると beamer は内部で amsmath を読み込み,ユーザーが overlay を指示していなくても equation 内での overlay のための内部的なラベルを作る.これとユーザーが指示した label とがダブって登録され,PDF を作る段になって警告が出る,こんなこと,よく知っていますね.

このダブりは基本的には無害だけれども,きれいなログが欲しければ,overlay-aware なラベルを書いてはどうかということで,
\begin{equation}\label<1>{eqn:quadratic_formula}
を提案されました.

試してみたところ,私の環境ではやはり同じ警告が出ました.Gemini に文句を言うと,beamer の内部に手を入れる次の方法を提案してきました.
\documentclass{beamer}
\makeatletter
% removed \beamer@nameslide{#2}:
\def\beamer@label@in@display<#1>#2{%
\alt<#1>{\xdef\@currentHref{#2}\beamer@origlabel@in@display{#2}}{\beamer@dummynameslide}%
}
\makeatother

これでようやく警告が出なくなりました.なんでこんなこと知っているのでしょうね?Beamer 内部の仕組みを変更しているので副作用が無いか少々心配ですが,今のところはうまく行っているように思えますので,当座はこの方法でしのぎたいと思います.検討していただいた和田様,あるいはほかの皆様,ありがとうございました.何か他に解があれば,後日でかまいませんので後学のためにご教示ください.
Toshio Otaguro への返信

Re: beamer の数式ラベルが二重に登録される

- Toshio Otaguro の投稿
すみません,再現ソースをペーストするとき間違いがありました.正しい再現ソースは以下のとおりです.

\documentclass{beamer}
\begin{document}
\begin{frame}{label to formula}
The solutions of a quadratic equation are,
\begin{equation}\label{eqn:quadratic_formula}
x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}.
\end{equation}
\end{frame}
\end{document}