tcolorbox 内の 2 つの脚注マークは同じラベルの脚注を生成します。

tcolorbox 内の 2 つの脚注マークは同じラベルの脚注を生成します。

footnotesを の下部ではなくページの下部に表示するには、の内側との下をtcolorbox使用します。以下は MWE です。\footnotemarktcolorbox\footnotetexttcolorbox

\documentclass[11pt]{book}
\usepackage{tcolorbox}

\begin{document}
\begin{tcolorbox}
This is a \textbf{tcolorbox}\footnotemark.

And this is some text.\footnotemark. 
\end{tcolorbox}
\footnotetext{This is footnote 1}
\footnotetext{This is footnote 2}
And more text.\footnote{This is footnote 3}
\end{document}

出力は次のようになります: (画像のサイズを適切に保つために、少し偽造する必要がありました):

出力

ページの下部では、脚注 2 と脚注 3 は両方とも正しく 2 と 3 とラベル付けされていますが、脚注 1 は誤って 2 とラベル付けされていることに注意してください。

答え1

この問題の原因は とは関係ありません。 はtcolorbox、が適用されるたびに上書きされる を\footnotetext使用するため、 を複数回呼び出すとカウンタが増加しますが、それらの脚注カウンタ値と対応する との関連付けはありません。 を複数回指定しても、関連する脚注カウンタ ラベルは増加しません。\@thefnmark\footnotemark\footnotemarkfootnote\footnotetext\footnotetext

代わりに、グループ内のカウンター\footnotetext[value]{...}を設定するものを使用することもできます。外部に漏れることはありません。footnote

以下のソリューションは、呼び出し回数を追跡し\footnotemarkてそれにラベルを割り当て、\morefootnotetextラベルを取得してカウンター値を抽出し、 でタイプセットします\footnotetext[value]{...}

\footnotetext割り当てよりも呼び出しの数が多い場合、このアプローチは失敗します\footnotemark

\documentclass[11pt]{book}
\usepackage{xassoccnt}
\usepackage{tcolorbox}
\usepackage{refcount}

\newcounter{totalfootnotes}
\newcounter{totalfootnotetexts}

\DeclareAssociatedCounters{footnote}{totalfootnotes}% Count all footnotes

\usepackage{xpatch}
\usepackage{xparse}
\xpatchcmd{\footnotemark}{\stepcounter}{\refstepcounter}{}{}
\xapptocmd{\footnotemark}{\label{fnmark-\number\value{totalfootnotes}}}{}{}
\xpretocmd{\footnote}{\stepcounter{totalfootnotetexts}}{}{}% Explicitly step!


\NewDocumentCommand{\morefootnotetext}{o+m}{%
  \IfValueTF{#1}{%
    \footnotetext[#1]{#2}%
  }{%
    \stepcounter{totalfootnotetexts}%
    \footnotetext[\getrefnumber{fnmark-\number\value{totalfootnotetexts}}]{#2}
  }%
}


\begin{document}
\begin{tcolorbox}
This is a \textbf{tcolorbox}\footnotemark

And this is some text.\footnotemark
\end{tcolorbox}
\morefootnotetext{This is footnote 1 from inside}
\morefootnotetext{This is footnote 2 from inside}
And more text.\footnote{This is footnote 3 from outside}

Now an example with 4 footnotemark\footnote{A dummy footnote} calls
\begin{tcolorbox}
This is a \textbf{tcolorbox}\footnotemark

And this is some text.\footnotemark

Stuff\footnotemark Otherstuff\footnotemark
\end{tcolorbox}
\morefootnotetext{This is footnote 3 from inside}
\morefootnotetext{This is footnote 4 from inside}
\morefootnotetext{This is footnote 5 from inside}
\morefootnotetext{This is footnote 6 from inside}

\end{document}

ここに画像の説明を入力してください

関連情報