
Para obtener el footnotes
en la parte inferior de la página en lugar de en la parte inferior de tcolorbox
, uso \footnotemark
dentro tcolorbox
y \footnotetext
debajo de tcolorbox
. Aquí hay un 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}
y aquí está el resultado: (tuve que fingir un poco para mantener el tamaño de la imagen razonable):
Tenga en cuenta que, en la parte inferior de la página, la nota al pie 2 y la nota al pie 3 están etiquetadas correctamente como 2 y 3, mientras que la nota al pie 1 está etiquetada incorrectamente como 2.
Respuesta1
La causa de este problema no tiene nada que ver con tcolorbox
los \footnotetext
usos \@thefnmark
que se sobrescriben cada vez \footnotemark
que se aplica, por lo que varias llamadas \footnotemark
aumentarán el footnote
contador, pero no hay asociación de esos valores del contador de notas al pie con el correspondiente \footnotetext
. Varias especificaciones de \footnotetext
no aumentan la etiqueta del contador de notas al pie correspondiente.
En su lugar , es posible utilizarlo \footnotetext[value]{...}
, lo que configura el footnote
contador en un grupo: no se filtrará al exterior.
La siguiente solución rastrea el número de \footnotemark
llamadas y le asigna una etiqueta, \morefootnotetext
recupera la etiqueta y extrae el valor del contador, que luego se escribe con \footnotetext[value]{...}
.
¡Este enfoque fracasará si hay más \footnotetext
llamadas que \footnotemark
asignaciones!
\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}