
각주와 너비를 조정할 수 있는 열이 포함된 큰 테이블(페이지 나누기)을 만들려고 합니다. MWE는 다음과 같습니다.
\documentclass{scrartcl}
\usepackage{blindtext}
\usepackage{tabu,longtable}
\usepackage{threeparttable} % <-- the package below already loads it
\usepackage[referable]{threeparttablex}
\usepackage{booktabs}
\usepackage{tabularx}
\usepackage{hyperref}
\usepackage{etoolbox}
\makeatletter
\chardef\TPT@@@asteriskcatcode=\catcode`*
\catcode`*=11
\expandafter\patchcmd\csname\string\threeparttable\endcsname
{\TPT@hookin{tabular}}
{\TPT@hookin{tabular}\TPT@hookin{tabu}}
{}{}
\catcode`*=\TPT@@@asteriskcatcode
\makeatother
\begin{document}
\listoftables
\bigskip
\blindtext
\begin{ThreePartTable}
\begin{TableNotes}
\footnotesize
\item[a] \label{tn:aa} Footnote in long table 1 (not linked).
\item[b] \label{tn:bb} Footnote in long table 2.
\source Some general note
\end{TableNotes}
\captionof{table}{A long table} % <-- caption inside longtabu within ThreePartTable does not produce correct hyperlink in LOT
\vspace{-\abovecaptionskip} % <-- removes the extra space (correct value?)
\begin{longtabu}to\linewidth{llX}
%\caption{A long table} \\ % <-- see above why it is commented
\toprule
Column 1 & & Column 2 \\
\midrule
\endfirsthead
\caption[]{A long table} \\
\toprule
Column 1 & & Column 2 \\
\midrule
\endhead
\cmidrule{3-3}
\multicolumn{3}{r}{\small\textit{continued}}
\endfoot
\bottomrule
\insertTableNotes\\
\endlastfoot
AAAA\tnotex*{tn:aa} & & BBBB \\
\newpage % <-- just testing break page
CCCC & & DDDD\tnotex{tn:bb} \\
\end{longtabu}
\end{ThreePartTable}
\blindtext
\end{document}
문제는 \caption{}
ThreePartTable 내의 longtabu 내부가 LOT에서 올바른 하이퍼링크를 생성하지 않는다는 것입니다. 그래서 저는 \captionof{}
. 그러나 이는 캡션과 테이블의 첫 번째 줄 사이에 일관성 건너뛰기가 없기 때문에 좋지 않습니다. 사용하고 싶은데 \caption{}
해결방법 아시는 분 계신가요?
답변1
아래 솔루션이 작동합니다. 나는 더미 카운터를 정의하고 \refstepcounter{dummy}
참조 시스템을 신비하게 수정하는 데 사용했습니다.
그러나 저는 좀 더 우아한 해결책을 갖고 싶습니다. \setdummy
longtabu를 사용할 때마다 호출하고 \vspace{-\baselineskip}
.
\documentclass[captions=tableheading]{scrartcl}
\usepackage{blindtext}
\usepackage{hyperref}
\usepackage{tabu,longtable}
%\usepackage{threeparttable} % the package below already loads it
\usepackage[referable]{threeparttablex}
\usepackage{booktabs}
\usepackage{caption}
\usepackage{etoolbox}
\makeatletter
\chardef\TPT@@@asteriskcatcode=\catcode`*
\catcode`*=11
\expandafter\patchcmd\csname\string\threeparttable\endcsname
{\TPT@hookin{tabular}}
{\TPT@hookin{tabular}\TPT@hookin{tabu}} % allow threeparttable with tabu
{}{}
\catcode`*=\TPT@@@asteriskcatcode
\makeatother
\makeatletter
\newcounter{dummy}
\newcommand{\setdummy}{\refstepcounter{dummy}\addtocounter{dummy}{-1}}
\makeatother
\begin{document}
\listoftables
\bigskip
\blindtext
\begin{ThreePartTable}
\begin{TableNotes}
\footnotesize
\item[a] \label{tn:aa} A note
\item[b] Another note
\end{TableNotes}
\vspace{-\baselineskip} % correct the \\ in \setdummy
\begin{longtabu}{ll}
\setdummy \\
\caption{A long table}
\label{tab:test1} \\
\toprule
Column 1 & Column 2 \\
\endfirsthead
\toprule
Column 1 & Column 2 \\
\midrule
\endhead
\cmidrule{2-2}
\multicolumn{2}{r}{\textit{continued}}
\endfoot
\bottomrule
\insertTableNotes
\endlastfoot
% the contents of the table
A & B\tnotex{tn:aa} \\
%\newpage % just testing page break
C\tnote{b} & D \\
\end{longtabu}
\end{ThreePartTable}
\blindtext
\begin{table}[h]
\centering
\caption{A regular table}
\label{tab:test2}
\begin{tabu}{ll}
\toprule
Column 1 & Column 2 \\
\midrule
A & B \\
\midrule
C & D \\
\bottomrule
\end{tabu}
\end{table}
\blindtext
\end{document}