我对 longtable 的标题和引用有疑问
\documentclass[stu,12pt]{apa7}
\usepackage[american]{babel}
\usepackage{setspace}
\usepackage{longtable}
\usepackage[style=apa,sortcites=true,sorting=nyt,backend=biber]{biblatex}
\DeclareLanguageMapping{american}{american-apa}
\title{title}
\begin{document}
\maketitle
Winter is cold in \ref{column_table}
\begin{center}
\begin{longtable}{p{0.4cm} | p{5cm} | p{2.5cm} | p{2.5cm} | p{2.3cm}}
\caption{Seasons of Island A}
\label{column_table}
\endfirsthead
\endhead
\hline
& Season & Temp & Length & Popular \\ \hline
1 & Spring & Warm & Nominal & Yes \\ \hline
2 & Summer & Hot & Nominal & Yes \\ \hline
3 & Winter & Cold & Nominal & Yes \\ \hline
\end{longtable}
\end{center}
\end{document}
我可以将表格标题格式化为在同一行上显示表格编号和标题吗,例如“表格 1 岛屿 A 的季节”?此外,是否可以通过表格名称来引用表格,例如“表格 1 中的冬季很冷”,而不仅仅是使用数字?
答案1
另一种方法是使用表格longtblr
或talltblr
包tabularray
。在这种情况下,标题格式由包定义tabularray
:
\documentclass[stu,12pt]{apa7}
\usepackage[american]{babel}
\usepackage[style=apa,sortcites=true,sorting=nyt,backend=biber]{biblatex}
\DeclareLanguageMapping{american}{american-apa}
\usepackage{tabularray} % <--- instead of longtable
\title{title}
\begin{document}
\maketitle
Winter is cold in \ref{long_table} and \ref{tall_table} \dots
\begin{longtblr}[
caption = {Seasons of Island A},
label = {long_table}
]
{hlines, vlines,
colspec = {l Q[l, wd=5cm] *{3}{Q[l, wd=2.5cm]}},
rowhead = 1
}
% table body
& Season & Temp & Length & Popular \\
1 & Spring & Warm & Nominal & Yes \\
2 & Summer & Hot & Nominal & Yes \\
3 & Winter & Cold & Nominal & Yes \\
\end{longtblr}
\begin{center}
\begin{talltblr}[
caption = {Seasons of Island A},
label = {tall_table}
]
{hlines, vlines,
colspec = {l X[l] *{3}{Q[l, wd=2.5cm]}}
}
% table body
& Season & Temp & Length & Popular \\
1 & Spring & Warm & Nominal & Yes \\
2 & Summer & Hot & Nominal & Yes \\
3 & Winter & Cold & Nominal & Yes \\
\end{talltblr}
\end{center}
\begin{center}
\begin{talltblr}[
caption = {Seasons of Island A, but this time the caption test is so long that it is broken into two lines},
label = {tall_table}
]
{hlines, vlines,
colspec = {l X[l] *{3}{Q[l, wd=2.5cm]}}
}
% table body
& Season & Temp & Length & Popular \\
1 & Spring & Warm & Nominal & Yes \\
2 & Summer & Hot & Nominal & Yes \\
3 & Winter & Cold & Nominal & Yes \\
\end{talltblr}
\end{center}
并保留 APA7 标题格式:
\begin{center}
\begin{talltblr}[
caption = {Seasons of Island A, but this time the caption test is so long that it is break into two lines},
label = {tblr_table}
]
{hlines, vlines,
colspec = {l X[l] *{3}{Q[l, wd=2.5cm]}}
}
% table body
& Season & Temp & Length & Popular \\
1 & Spring & Warm & Nominal & Yes \\
2 & Summer & Hot & Nominal & Yes \\
3 & Winter & Cold & Nominal & Yes \\
\end{talltblr}
\end{center}
but when you like to preserve original APA7 caption formatting at short tables, you should use `tblr` inserted in `center` environment:
\begin{center}
\captionof{table}{Seasons of Island A}
\label{tblr_table}
\begin{tblr}{hlines, vlines,
colspec = {l X[l] *{3}{Q[l, wd=2.5cm]}}
}
% table body
& Season & Temp & Length & Popular \\
1 & Spring & Warm & Nominal & Yes \\
2 & Summer & Hot & Nominal & Yes \\
3 & Winter & Cold & Nominal & Yes \\
\end{tblr}
\end{center}
\end{document}