
Um das footnotes
am unteren Ende der Seite statt am unteren Ende des zu erhalten tcolorbox
, verwende ich \footnotemark
innerhalb des tcolorbox
und \footnotetext
unterhalb des tcolorbox
. Hier ist ein MWE:
\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}
und hier ist die Ausgabe: (Ich musste es ein wenig vortäuschen, um die Größe des Bildes in einem vernünftigen Rahmen zu halten.):
Beachten Sie, dass unten auf der Seite Fußnote 2 und Fußnote 3 beide korrekt als 2 und 3 gekennzeichnet sind, während Fußnote 1 fälschlicherweise mit 2 gekennzeichnet ist.
Antwort1
Die Ursache für dieses Problem hat nichts mit zu tun tcolorbox
-- \footnotetext
Verwendungen \@thefnmark
, die bei jeder \footnotemark
Anwendung überschrieben werden, sodass mehrere Aufrufe von \footnotemark
den Zähler erhöhen, footnote
aber es besteht keine Verbindung dieser Fußnotenzählerwerte mit den entsprechenden \footnotetext
. Mehrfache Angaben von \footnotetext
erhöhen die entsprechende Fußnotenzählerbezeichnung nicht.
Es ist möglich, stattdessen zu verwenden \footnotetext[value]{...}
, was den footnote
Zähler in einer Gruppe einstellt – er wird nicht nach außen gelangen.
Die folgende Lösung verfolgt die Anzahl der \footnotemark
Anrufe, weist ihnen eine Bezeichnung zu, \morefootnotetext
ruft die Bezeichnung ab und extrahiert den Zählerwert, der dann mit gesetzt wird \footnotetext[value]{...}
.
Dieser Ansatz schlägt fehl, wenn es mehr \footnotetext
Anrufe als \footnotemark
Zuweisungen gibt!
\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}