定制后,标签和注释在 threeparttablex 中分离

定制后,标签和注释在 threeparttablex 中分离

我尝试去适应Donald Arseneau 的解决方案可以使用但失败了。原始解决方案解决了使用的设置threeparttablex时(在我看来)过多的注释必须与标签放在同一行的问题。但经过我的调整,似乎标签甚至可以与注释的第一部分放在不同的行上。threeparttablepara

使用threeparttableArseneau 的解决方案,该表看起来符合预期:

threeparttable 示例

\documentclass{article}
\usepackage{booktabs}
\usepackage[para,flushleft]{threeparttable}
% Arseneau's solution: https://tex.stackexchange.com/a/564293/71332
\makeatletter
\def\TPT@doparanotes{\par
   \prevdepth\z@ \TPT@hsize
   \TPTnoteSettings
   \parindent\z@ \pretolerance 8
   \linepenalty 200
   \renewcommand\item[2][]{\relax\ifhmode \begingroup
       \unskip
       \penalty -45 \hskip\z@\@plus 10pt\penalty-19
       \hskip 25pt \penalty 9999 \hskip-25pt
       \hskip 1em\@plus3pt
      \endgroup\fi
      \tnote{##1}\,\ignorespaces}%
   \let\TPToverlap\relax
   \def\endtablenotes{\par}%
}
\makeatother
\begin{document}
  \begin{threeparttable}
    \caption{A table}
    \begin{tabular}{l r r}
      \toprule
      & A & B \\
      \midrule
      A first row that goes on for a bit\tnote{a} & 123 & 456 \\
      A second row & 123 & 456 \\
      \bottomrule
    \end{tabular}
    \begin{tablenotes}
      \textit{Note:} This note is really rather short.
      \textit{Source:} This source is really quite strange iiiiiiiii.
      \item[a] This is a note.
    \end{tablenotes}
  \end{threeparttable}
\end{document}

但我无法采用 Arseneau 的解决方案,threeparttablex因为标签现在与注释的第一部分位于不同的行上。

threeparttablex 示例

\documentclass{article}
\usepackage{booktabs}
\usepackage[referable,para,flushleft]{threeparttablex}

% My own attempt to adapt https://tex.stackexchange.com/a/564293/71332 to threeparttablex
\makeatletter
\def\TPT@doparanotes{\par
   \prevdepth\z@ \TPT@hsize
   \TPTnoteSettings
   \parindent\z@ \pretolerance 8
   \linepenalty 200
   \renewcommand\item[2][]{\relax\ifhmode \begingroup
       \unskip
       \penalty -45 \hskip\z@\@plus 10pt\penalty-19
       \hskip 25pt \penalty 9999 \hskip-25pt
       \hskip 1em\@plus3pt
      \endgroup\fi
      \tnote{##1}%
      \phantomsection\protected@edef\@currentlabel{##1}%
      \,\ignorespaces}%
    \let\TPToverlap\relax%
    \TPTL@generator@para\note{\TPTLnotename}%
    \TPTL@generator@para\source{\TPTLsourcename}%
    \TPTL@font%
    \def\endtablenotes{\par}%
  }
\makeatother

\begin{document}
  \begin{threeparttable}
    \caption{A table}
    \begin{tabular}{l r r}
      \toprule
      & A & B \\
      \midrule
      A first row that goes on for a bit\tnotex*{tn:item_a} & 123 & 456 \\
      A second row & 123 & 456 \\
      \bottomrule
    \end{tabular}
    \begin{tablenotes}
      \note This note is really rather short.
      \source This source is really quite strange iiiiiiiii.
      \item[a] \label{tn:item_a} This is a note.
    \end{tablenotes}
  \end{threeparttable}
\end{document}

相关内容