当两个表处于同一环境中时,通过 subfloat 在 tabularx 上添加脚注

当两个表处于同一环境中时,通过 subfloat 在 tabularx 上添加脚注

我目前有两张用该tabularx包制作的并排表格。我使用包subfloat的命令将它们并排放置subfig(如建议的那样这里),这样我就可以为每张表格分别写一个标题(并引用)为 1.1a 和 1.1b。

我的问题如下:这些表格中有一些值必须共享一个脚注。当我尝试使用该\footnote{text}命令时,脚注的编号会出现,但文本不会出现。

我该如何解决这个问题?如果可能的话,我希望文本出现在桌子,但如果它出现在页面底部就没那么可怕了。

提前谢谢您。我添加了一个 MWE,其中带星号的数字应该有我提到的脚注。

\documentclass[letterpaper]{article}

\usepackage{subfig}
\usepackage{tabularx, booktabs}
\newcolumntype{Y}{>{\centering\arraybackslash}X}

\begin{document}

\begin{table}[ht]
    \centering
    \caption{Title of the two-table-environment.}
    \label{table:environment}
    \subfloat[Title of the first table]{
    \label{table:first_table}
    \begin{tabularx}{0.5\textwidth}{lc*{2}{Y}}
        \toprule
        & \multicolumn{2}{>{\setlength\hsize{2\hsize}}Y}{Text too long spanning two columns yay!}\\ \cmidrule(l){2-3}
        Column 1    & Metric 1  & Metric 2 \\ \midrule
        Context 1   & $100*$    & $0.5336$\\
        Context 2   & $100$     & $0.2109$\\
        Context 3   & $100*$    & $0.3897$\\
        Context 4   & $100*$    & $-0.1376$\\
        Context 5   & $100*$    & $-0.7640$\\
        Context 6   & $100$     & $-0.0792$\\
        Context 7   & $100*$    & $-11.4119$\\
        \bottomrule
    \end{tabularx}
    }
    \subfloat[Title of the second table]{
    \label{table:second_table}
    \begin{tabularx}{0.5\textwidth}{lc*{2}{Y}}
        \toprule
        & \multicolumn{2}{>{\setlength\hsize{2\hsize}}Y}{Text too long spanning two columns hooray!}\\ \cmidrule(l){2-3}
        Column 1    & Metric 1  & Metric 2 \\ \midrule
        Context 1   & $40.7359$ & $53.7044$\\
        Context 2   & --        & -- \\
        Context 3   & $46.6164$ & $16.2185$\\
        Context 4   & --        & -- \\
        Context 5   & $28.4038$ & $70.5398$\\
        Context 6   & $57.4703$ & $59.2224$\\
        Context 7   & --        & -- \\
        \bottomrule
    \end{tabularx}
    }
\end{table}

\end{document}

答案1

你可以稍微作弊,将脚注放在表格下方的一行中。由于你使用的是tabularx,所以你可以用 来做\multicolumn。我倾向于将这种脚注放在用 分隔的内联枚举中\quad。将\label附加到你的项目中,你可以将\ref它们放回去。

还要注意,代码中有一连串不需要的空格,你必须在行%尾隐藏它们。此外,你定义了 4 列lc*{2}{Y},但只使用了 3 列。代码:

\documentclass[letterpaper]{article}

\usepackage{subfig}
\usepackage{tabularx, booktabs}
\newcolumntype{Y}{>{\centering\arraybackslash}X}

\usepackage[showframe]{geometry}
\usepackage[inline]{enumitem}

\begin{document}

\begin{table}[ht]
  \centering
  \caption{Title of the two-table-environment.}
  \label{table:environment}
  \subfloat[Title of the first table]{%
    \label{table:first_table}%
    \begin{tabularx}{0.49\textwidth}{@{}l*{2}{Y}@{}}
      \toprule
      & \multicolumn{2}{>{\setlength\hsize{2\hsize}}Y}{%
        Text too long spanning two columns yay!}\\ \cmidrule(l){2-3}
      Column 1    & Metric 1  & Metric 2 \\ \midrule
      Context 1   & $100\ref{tab:fn1}$    & $0.5336$\\
      Context 2   & $100$     & $0.2109$\\
      Context 3   & $100\ref{tab:fn2}$    & $0.3897$\\
      Context 4   & $100\ref{tab:fn1}$    & $-0.1376$\\
      Context 5   & $100\ref{tab:fn2}$    & $-0.7640$\\
      Context 6   & $100$     & $-0.0792$\\
      Context 7   & $100\ref{tab:fn1}$    & $-11.4119$\\
      \bottomrule
      \noalign{\vspace{3pt}}
      \multicolumn{3}{@{}p{0.49\textwidth}@{}}{%
        \raggedright\footnotesize
        \begin{enumerate*}[itemjoin=\quad,ref=\textsuperscript{\arabic*}]
        \item My footnote\label{tab:fn1}
        \item My other referenced footnote which is also longer\label{tab:fn2}
        \end{enumerate*}}
    \end{tabularx}%
  }%
  \hfill
  \subfloat[Title of the second table]{%
    \label{table:second_table}%
    \begin{tabularx}{0.49\textwidth}{@{}l*{2}{Y}@{}}
      \toprule
      & \multicolumn{2}{>{\setlength\hsize{2\hsize}}Y}{%
        Text too long spanning two columns hooray!}\\ \cmidrule(l){2-3}
      Column 1    & Metric 1  & Metric 2 \\ \midrule
      Context 1   & $40.7359$ & $53.7044$\\
      Context 2   & --        & -- \\
      Context 3   & $46.6164$ & $16.2185$\\
      Context 4   & --        & -- \\
      Context 5   & $28.4038$ & $70.5398$\\
      Context 6   & $57.4703$ & $59.2224$\\
      Context 7   & --        & -- \\
      \bottomrule
    \end{tabularx}%
  }%
\end{table}

\begin{table}[ht]
    \centering
    \caption{Title of the two-table-environment with spurious spaces}
    \label{table:environment}
    \subfloat[Title of the first table]{
    \label{table:first_table}
    \begin{tabularx}{0.5\textwidth}{lc*{2}{Y}}
        \toprule
        & \multicolumn{2}{>{\setlength\hsize{2\hsize}}Y}{Text too long spanning two columns yay!}\\ \cmidrule(l){2-3}
        Column 1    & Metric 1  & Metric 2 \\ \midrule
        Context 1   & $100*$    & $0.5336$\\
        Context 2   & $100$     & $0.2109$\\
        Context 3   & $100*$    & $0.3897$\\
        Context 4   & $100*$    & $-0.1376$\\
        Context 5   & $100*$    & $-0.7640$\\
        Context 6   & $100$     & $-0.0792$\\
        Context 7   & $100*$    & $-11.4119$\\
        \bottomrule
    \end{tabularx}
    }
    \subfloat[Title of the second table]{
    \label{table:second_table}
    \begin{tabularx}{0.5\textwidth}{lc*{2}{Y}}
        \toprule
        & \multicolumn{2}{>{\setlength\hsize{2\hsize}}Y}{Text too long spanning two columns hooray!}\\ \cmidrule(l){2-3}
        Column 1    & Metric 1  & Metric 2 \\ \midrule
        Context 1   & $40.7359$ & $53.7044$\\
        Context 2   & --        & -- \\
        Context 3   & $46.6164$ & $16.2185$\\
        Context 4   & --        & -- \\
        Context 5   & $28.4038$ & $70.5398$\\
        Context 6   & $57.4703$ & $59.2224$\\
        Context 7   & --        & -- \\
        \bottomrule
    \end{tabularx}
    }
\end{table}

\end{document}

在此处输入图片描述

答案2

我建议您使用手动脚注,即在第一个表格中添加一个额外的行,并将脚注文本放在\multicolumn跨越正确列数的命令中。脚注标记可以放在\textsuperscript两个表格中正确位置的 - 命令中。

看看这个答案以获得进一步的描述和代码示例。

答案3

您可以将 放在tabular内部minipage(在 内部\subfloat,如果不是,则放在 内部)。请注意,脚注在 minipages 中的行为完全不同。另请注意 的minipage更改\textwidth

我添加了命令 \repeatfootnote,以防您想在所有内容上使用相同的脚注(从上下文来看这似乎是可能的) \footnotemark不是\footnote在 内匹配minipage

\documentclass[letterpaper]{article}

\usepackage{subfig}
\usepackage{tabularx, booktabs}
\newcolumntype{Y}{>{\centering\arraybackslash}X}

\makeatletter
\newcommand{\repeatfootnote}[1][\empty]% #1 = \thempfn for this mark (optonal)
 {\ifx\empty#1\relax \@makefnmark
  \else\hbox{\@textsuperscript{\itshape #1}}%
  \fi}
\makeatother

\begin{document}

\begin{table}[ht]
    \centering
    \caption{Title of the two-table-environment.}
    \label{table:environment}
    \subfloat[Title of the first table]{%
    \label{table:first_table}
    \begin{minipage}{0.49\textwidth}
    \begin{tabularx}{\textwidth}{lc*{2}{Y}}
        \toprule
        & \multicolumn{2}{>{\setlength\hsize{2\hsize}}Y}{Text too long spanning two columns yay!}\\ \cmidrule(l){2-3}
        Column 1    & Metric 1  & Metric 2 \\ \midrule
        Context 1   & $100\footnote{test}$    & $0.5336$\\
        Context 2   & $100$     & $0.2109$\\
        Context 3   & $100\footnote{another}$    & $0.3897$\\
        Context 4   & $100\repeatfootnote$    & $-0.1376$\\
        Context 5   & $100\repeatfootnote[a]$    & $-0.7640$\\
        Context 6   & $100$     & $-0.0792$\\
        Context 7   & $100\repeatfootnote[b]$    & $-11.4119$\\
        \bottomrule
    \end{tabularx}%
    \end{minipage}%
    }\hfill
    \subfloat[Title of the second table]{%
    \label{table:second_table}
    \begin{tabularx}{0.49\textwidth}{lc*{2}{Y}}
        \toprule
        & \multicolumn{2}{>{\setlength\hsize{2\hsize}}Y}{Text too long spanning two columns hooray!}\\ \cmidrule(l){2-3}
        Column 1    & Metric 1  & Metric 2 \\ \midrule
        Context 1   & $40.7359$ & $53.7044$\\
        Context 2   & --        & -- \\
        Context 3   & $46.6164$ & $16.2185$\\
        Context 4   & --        & -- \\
        Context 5   & $28.4038$ & $70.5398$\\
        Context 6   & $57.4703$ & $59.2224$\\
        Context 7   & --        & -- \\
        \bottomrule
    \end{tabularx}%
    }
\end{table}

\end{document}

相关内容