我想为浮动环境创建自己的脚注命令:
%begin figure
bla\myFootnote{XXX}
blabla\myFootnote{YYY}
blabla\myFootnote{ZZZ}
%end figure
some text
\printSavedFootnotes
命令如下:
\global\def\footnoteStore{}
\global\def\footnoteSeparator{}
\global\def\firstSkip{1}
\newcommand{\myFootnote}[1]{\addtocounter{footnote}{\firstSkip}\footnotemark[\thefootnote]
\global\edef\footnoteStore{\footnoteStore\footnoteSeparator\thefootnote/#1}
\addtocounter{footnote}{1}
\global\edef\footnoteSeparator{,}
\global\edef\firstSkip{0}
}
\newcommand{\printSavedFootnotes}{
\begin{tikzpicture}
\foreach \i/\j in{\footnoteStore}{
\footnotetext[\i]{\j}
}
\global\edef\footnoteStore{}
\global\edef\footnoteSeparator{}
\end{tikzpicture}
}
但对于\foreach
我必须使用的\tikzpicture
,然后就不能使用了\footnotetext
:(
有什么解决方案可以\foreach
在盒子外面使用还是使用\footnotetext
tikzpicture 的内部?
谢谢 :)
答案1
请注意,打印后会将脚注索引重置为零。如果您想要不重复的数字或使用脚注计数器,也可以这样做。
\documentclass{article}
\newcount\mycount
\makeatletter
\newcommand{\myFootnote}[1]% #1 = text
{\global\advance\mycount by 1
\@textsuperscript{\@fnsymbol\mycount}
\global\expandafter\def\csname myfootnote\the\mycount\endcsname{#1}% if #1 contains any macros, use \def not \edef
}
\newcommand{\printSavedFootnotes}%
{\par\bgroup
\countdef\index=1
\index=0
\loop\ifnum\index<\mycount\relax
\advance\index by 1
\noindent\hbox to 1em{\@textsuperscript{\@fnsymbol\index}}%
\parbox[t]{\dimexpr\textwidth-1em}{\footnotesize\csname myfootnote\the\index\endcsname\strut}\par
\repeat% no \fi needed
\egroup
\global\mycount=0
}
\makeatother
\begin{document}
\begin{figure}
bla\myFootnote{XXX}
blabla\myFootnote{A very very very very very very long footnote in order to demonstrate the hanging indentation.}
blabla\myFootnote{ZZZ}
\end{figure}
some text
\printSavedFootnotes
\end{document}