\footnotetext numbering for many \footnotemark - automatic solution
\documentclass{report}
\begin{document}
Text\footnote{text1} Text\footnote{text2}
\begin{itemize}
\item X\footnotemark{} \item Y\footnotemark{} \item Z\footnotemark{}
\end{itemize}
\addtocounter{footnote}{-3} %3=n
\stepcounter{footnote}\footnotetext{a}
\stepcounter{footnote}\footnotetext{b}
\stepcounter{footnote}\footnotetext{c}
\end{document}
An alternative would be to fix the environment to not need this, and lift the footnotes out of the environment so manual correction isn't needed.
tabularx
for example does
\let\@footnotetext\TX@ftntext\let\@xfootnotenext\TX@xftntext
at the start of the environment and
\global\TX@ftn\expandafter{\expandafter}\the\TX@ftn
at the end, where \TX@ftntext
is
% \begin{macro}{\TX@ftntext}
% \begin{macro}{\TX@xftntext}
% Inside the alignment just save up the footnote text in a token
% register.
% \begin{macrocode}
\long\def\TX@ftntext#1{%
\edef\@tempa{\the\TX@ftn\noexpand\footnotetext
[\the\csname c@\@mpfn\endcsname]}%
\global\TX@ftn\expandafter{\@tempa{#1}}}%
\long\def\TX@xftntext[#1]#2{%
\global\TX@ftn\expandafter{\the\TX@ftn\footnotetext[#1]{#2}}}
% \end{macrocode}
% \end{macro}
% \end{macro}
So putting it all into your example:
\documentclass{report}
\makeatletter
\newtoks\FTN@ftn
\def\pushftn{%
\let\@footnotetext\FTN@ftntext\let\@xfootnotenext\FTN@xftntext
\let\@xfootnote\FTN@xfootnote}
\def\popftn{%
\global\FTN@ftn\expandafter{\expandafter}\the\FTN@ftn}
\long\def\FTN@ftntext#1{%
\edef\@tempa{\the\FTN@ftn\noexpand\footnotetext
[\the\csname c@\@mpfn\endcsname]}%
\global\FTN@ftn\expandafter{\@tempa{#1}}}%
\long\def\FTN@xftntext[#1]#2{%
\global\FTN@ftn\expandafter{\the\FTN@ftn\footnotetext[#1]{#2}}}
\def\FTN@xfootnote[#1]{%
\begingroup
\csname c@\@mpfn\endcsname #1\relax
\unrestored@protected@xdef\@thefnmark{\thempfn}%
\endgroup
\@footnotemark\FTN@xftntext[#1]}
\makeatother
\begin{document}
Text\footnote{text1} Text\footnote{text2}
fff\footnote[35]{jjjj}
\vbox{\pushftn
\begin{itemize}
\item X\footnote{a}
\item Y\footnote{b}
\item Z\footnote{c}
\item W fff\footnote[42]{kkk}
\end{itemize}
}\popftn
\end{document}
For tables the tablefootnote package implements the automation asked for (and also takes care of hyperlinks, when the hyperref package is used). (Please see its manual.pdf.) For other environments, the package can be "abused" (see explanation at my answer to "Nested footnotes disrupts comma delineation of footnotes"). It saves the (table)footnote(text)s and issues it/them after the end of the table environment. When you use a vbox
, it must be (manually) issued at its end, which \spewfootnotes
does. Complete automation would redefine \vbox
to include \spewfootnotes
after the end of the box and redefine \footnote
to be a \tablefootnote
inside of a \vbox
.
\documentclass{report}
\usepackage{hyperref}% if you want/for demonstration of hyperlinks
\usepackage{tablefootnote}
\makeatletter
\newcommand{\spewfootnotes}{%
\tfn@tablefootnoteprintout%
\global\let\tfn@tablefootnoteprintout\relax%
\gdef\tfn@fnt{0}%
}
\makeatother
\begin{document}
Text\footnote{text1} Text\footnote{text2}
\vbox{%
\begin{itemize}
\item X\tablefootnote{a}
\item Y\tablefootnote{b}
\item Z\tablefootnote{c}
\end{itemize}
}\spewfootnotes
Text\footnote{text7}
\newpage
Just to get another page to demonstrate the hyperlinks.
\end{document}