
表に複数の脚注を入れたいのですが、最初の脚注に到達するまでに脚注カウンタが何度も増加しすぎてしまいます\footnotetext
。これを正しく動作させるには、どのような方法が最適ですか?
\documentclass{article}
\begin{document}
\ \vfill\
\begin{tabular}{|r|l|}
\hline
First & footnote.\footnotemark \\
Second & footnote.\footnotemark \\
Third & footnote.\footnotemark \\
\hline
\end{tabular}
\footnotetext{First} \footnotetext{Second} \footnotetext{Third}
Fourth footnote.\footnote{Four}
\
\end{document}
答え1
はカウンター\footnotemark
の値を増加させますfootnote
が、 を使用すると同期が失われます\footnotetext
。
footnote
カウンターをリセットする必要がある後環境tabular
を国家に前にこれは手動でも実行できますが、値が変更される場合は面倒になる可能性があります。または、ダミー カウンターを使用して実行します。ダミー カウンターは、footnote
前のカウンターを保持しtabular
、実行後に元の数値に復元しますtabular
(ここでは、パッケージの\AtBeginEnvironment
および\AfterEndEnvironment
コマンドを使用して実行しますetoolbox
)。
ただし、\footnotetext
は を増分しませんfootnote
。pretocmd
-- アプローチを使用するか、このステップを自動的に実行するラッパー マクロを使用します\myfootnotetext
。 (または手動で実行します。)
\documentclass{article}
\newcommand{\myfootnotetext}[1]{%
\stepcounter{footnote}\footnotetext{#1}%
}
\newcounter{dummycounter}
\usepackage{etoolbox}
\AtBeginEnvironment{tabular}{%
\setcounter{dummycounter}{\value{footnote}}%
}
\AfterEndEnvironment{tabular}{%
\setcounter{footnote}{\value{dummycounter}}%
}
\begin{document}
\begin{tabular}{|r|l|}
\hline
First & footnote.\footnotemark \\
Second & footnote.\footnotemark \\
Third & footnote.\footnotemark \\
\hline
\end{tabular}
\myfootnotetext{First}
\myfootnotetext{Second} \myfootnotetext{Third}
Fourth footnote.\footnote{Four}
%\
\end{document}
答え2
環境の使用を検討している場合はtable
、tablefootnote
パッケージが問題を解決します。
\documentclass[colorlinks]{article}%
\usepackage{footnotebackref}
\usepackage{tablefootnote}
\begin{document}
\mbox{}\vfill
A first footnote\footnote{First}
\begin{table}[htbp]
\renewcommand\arraystretch{1.5}
\begin{tabular}{|r|l|}
\hline
First & footnote.\tablefootnote{Second} \\
Second & footnote.\tablefootnote{Third} \\
Third & footnote.\tablefootnote{Fourth} \\
\hline
\end{tabular}
\end{table}
Fifth footnote.\footnote{Fifth}
\end{document}