我想使用 threeparttable 包来标记脚注,但它似乎无法在没有适当标题的情况下分配标签。事实上,如果我禁用 \caption 包,它就可以工作。但我需要该包来设置字体大小。
\documentclass[12pt]{report}
\usepackage{lmodern}
\usepackage[utf8]{inputenc}
\usepackage{threeparttable}
\usepackage[font=small, labelfont=bf]{caption}
\usepackage{tikz}
\usetikzlibrary{matrix, backgrounds}
\tikzset{
table/.style={
matrix of nodes,
row sep=-\pgflinewidth,
column sep=-\pgflinewidth,
nodes={
rectangle,
align=center,
text width=10em,
},
nodes in empty cells,
row 1/.style={nodes={fill=black, text=white, font=\bfseries}, text height=0.8em},
}
}
\begin{document}
\begin{table}
\centering
\caption{Glossary: with \texttt{TikZ} drawing cells on background layer}
\label{tabA1}
\begin{threeparttable}
\begin{tikzpicture}
\matrix[table, ampersand replacement=\&] (TabA1)
{
A1 \& A2\stepcounter{footnote}\tnote{\thefootnote} \& A3 \\
B1\footnotemark{} \& B2 \& B3\footnotemark{} \\
C1 \& C2\textsuperscript{\ref{note1}} \& C3 \\
};
%\begin{scope}[on background layer]
%\foreach \i in {1,2,3}
%\draw[fill=black!10] ([xshift=\pgflinewidth]TabA1-1-\i.south west) rectangle ([xshift=-\pgflinewidth]TabA1-2-\i.south east);
%\end{scope}
\end{tikzpicture}
\addtocounter{footnote}{-3}
\begin{tablenotes}\footnotesize
\stepcounter{footnote}
\item[\thefootnote]{\label{note1} This is broken.}
\stepcounter{footnote}
\stepcounter{footnote}
\end{tablenotes}
\end{threeparttable}
\end{table}
\addtocounter{footnote}{-2}
\stepcounter{footnote}\footnotetext{This seems to be ok}
\stepcounter{footnote}\footnotetext{This seems to be ok too}
\end{document}
答案1
方法如下threeparttablex
:
\documentclass[12pt]{report}
\usepackage{lmodern}
\usepackage[utf8]{inputenc}
\usepackage{longtable}
\usepackage[referable]{threeparttablex}
\usepackage[font=small, labelfont=bf]{caption}
\usepackage{tikz}
\usetikzlibrary{matrix, backgrounds}
\tikzset{
table/.style={
matrix of nodes,
row sep=-\pgflinewidth,
column sep=-\pgflinewidth,
nodes={
rectangle,
align=center,
text width=10em,
},
nodes in empty cells,
row 1/.style={nodes={fill=black, text=white, font=\bfseries}, text height=0.8em},
}
}
\begin{document}
\begin{ThreePartTable}
\setTableNoteFont{\footnotesize}
\renewcommand\TPTminimum{\textwidth}
\begin{TableNotes}\footnotesize
\item[1] \label{note1} This is not broken.
\item[2]\label{note2} This seems to be ok.
\item[3]\label{note3} This seems to be ok too.
\end{TableNotes}
\begin{longtable}{p{\linewidth}}
\caption{Glossary: with \texttt{TikZ} drawing cells on background layer}
\label{tabA1}
\endfirsthead
\endfoot
\insertTableNotes \\
\endlastfoot
{\begin{tikzpicture}
\matrix[table, ampersand replacement=\&] (TabA1)
{
A1 \& A2\tnotex{note1} \& A3 \\
B1\tnotex{note2} \& B2 \& B3\tnotex{note3} \\
C1 \& C2\tnotex{note1} \& C3 \\
};
\end{tikzpicture}}
\end{longtable}
\end{ThreePartTable}
\end{document}