%% test-key-libs.tex
%% =================
%% Typesetting test for boxes of the libraries of tcolorbox, with
%% \tcbset{page footnote} for the whole document.
%%
%%   pdflatex test-key-libs.tex   (or xelatex / lualatex)
%%   platex  -jobname=test-key-libs "\def\CLS{jarticle}\input test-key-libs"
%%   (then dvipdfmx test-key-libs)
%%
%% What is covered:
%%   * raster: the boxes of a tcbraster, which gets "before" and "after"
%%     set for each box while the box starts: with the key from \tcbset,
%%     from "raster every box" and from the options of the boxes, and
%%     with "page footnote=false" for the boxes of a raster;
%%   * theorems: a box of \newtcbtheorem, with a footnote in its title;
%%   * skins: a boxed title ("attach boxed title to top left"), and
%%     "sidebyside";
%%   * \tcbincludegraphics, and a tcblisting (listings), which have no
%%     footnotes: no error with the key.
%%
%% What to check:
%%   * TPF-RESULT OK, TPF-COUNTER OK, and no error or warning.
\ifdefined\CLS\else\def\CLS{article}\fi
\ifdefined\ptexversion\def\CLSOPT{dvipdfmx}\else\def\CLSOPT{}\fi
\expandafter\documentclass\expandafter[\CLSOPT]{\CLS}
\usepackage{tcbpagefootnote}
\tcbuselibrary{breakable,raster,skins,theorems,listings}
\input{test-common}
\tcbset{page footnote}
\newtcbtheorem{TPFtheorem}{Theorem}{colback=green!5}{th}
\begin{document}
\section*{Raster}

\begin{tcbraster}[raster columns=2]
\begin{tcolorbox}
One\TPFfootnote{A footnote of the first box.}.
\end{tcolorbox}
\begin{tcolorbox}
Two\TPFfootnote{A footnote of the second box.}.
\end{tcolorbox}
\begin{tcolorbox}[after skip=3pt]
Three\TPFfootnote{A footnote of the third box.}.
\end{tcolorbox}
\end{tcbraster}

\begin{tcbraster}[raster columns=2,
  raster every box/.style={page footnote=false}]
\begin{tcolorbox}
One, with false\TPFfootnote[box]{A footnote of the box.}.
\end{tcolorbox}
\begin{tcolorbox}[page footnote]
Two, with the key again\TPFfootnote{A footnote of the second box.}.
\end{tcolorbox}
\end{tcbraster}

\begingroup
\tcbset{page footnote=false}
\begin{tcbraster}[raster columns=2,
  raster every box/.style={page footnote}]
\begin{tcolorbox}
One, with the key for the boxes of the raster\TPFfootnote{A footnote
  of the first box.}.
\end{tcolorbox}
\begin{tcolorbox}
Two\TPFfootnote{A footnote of the second box.}.
\end{tcolorbox}
\end{tcbraster}

\begin{tcbraster}[raster columns=2]
\begin{tcolorbox}[page footnote]
One, with the key in its options\TPFfootnote{A footnote of the first
  box.}.
\end{tcolorbox}
\begin{tcolorbox}
Two, without the key\TPFfootnote[box]{A footnote of the box.}.
\end{tcolorbox}
\end{tcbraster}
\endgroup

\section*{Theorems and skins}

\begin{TPFtheorem}{A title\TPFfootnote{A footnote of the title.}}{a}
A theorem\TPFfootnote{A footnote of the theorem.}.
\end{TPFtheorem}

\begin{tcolorbox}[enhanced, attach boxed title to top left,
  title={A boxed title}]
A box with a boxed title\TPFfootnote{A footnote of the box.}.
\end{tcolorbox}

\begin{tcolorbox}[sidebyside]
The left side\TPFfootnote{A footnote of the left side.}.
\tcblower
The right side\TPFfootnote{A footnote of the right side.}.
\end{tcolorbox}

\section*{Boxes without footnotes}

\tcbincludegraphics[width=3cm]{example-image-a}

\begin{tcblisting}{listing only}
\begin{tcolorbox}
A listing
\end{tcolorbox}
\end{tcblisting}

Text\TPFfootnote{A footnote of the body text.}.
\TPFcounter{footnote}{13}
\end{document}
