tabularray 中的 longtblr 未在表格列表中正确显示

tabularray 中的 longtblr 未在表格列表中正确显示

我的论文中有一些longtblr。它们在正文中显示正常,但在表格列表中存在一些问题(见附图):标题显示不正确,章节编号缺失。

在此处输入图片描述

我尝试将longtblr内部\begin{table} ... \end{table}和封闭起来\begin{tabular} ... \end{tabular},但出现了一些错误。有什么解决办法吗?

以下是 MWE:

\documentclass{book}

\usepackage{tabularray}
\usepackage{caption}
\usepackage{chngcntr} % This is to add section number before figure.

\begin{document}
    
\listoftables

\chapter{My Chapter 1}
Table \ref{tab:longtblrsample} is a long table created with tabularray.

\begin{longtblr}[
    caption = {Sample table with tabularray},
    label={tab:longtblrsample},
    ]{width=\textwidth,
        colspec = {X[c,m] X[c,m]},
        rowhead = 1,
    }
    Number 1 & Number 2 \\
    1 & 1 \\
    1 & 1 \\
    1 & 1 \\
    1 & 1 \\
    1 & 1 \\
    1 & 1 \\
    1 & 1 \\
    1 & 1 \\
    1 & 1 \\
    1 & 1 \\
    1 & 1 \\
    1 & 1 \\
    1 & 1 \\
    1 & 1 \\
    1 & 1 \\
    1 & 1 \\
    1 & 1 \\
    1 & 1 \\
    1 & 1 \\
    1 & 1 \\
    1 & 1 \\
    1 & 1 \\
    1 & 1 \\
    1 & 1 \\
    1 & 1 \\
    1 & 1 \\
    1 & 1 \\
    1 & 1 \\
    1 & 1 \\
    1 & 1 \\
    1 & 1 \\
    1 & 1 \\
    1 & 1 \\
    1 & 1 \\
    1 & 1 \\
    1 & 1 \\
    1 & 1 \\
    1 & 1 \\
\end{longtblr}

\end{document}

答案1

我无法重现您的问题。考虑到我在您的问题下方的评论,为了进行测试,我使用了以下测试 MWE:

\documentclass{book}
\usepackage{tabularray}
    \SetTblrStyle{caption-text}{font=\small\sffamily}
    \SetTblrStyle{caption-tag}{font=\small\bfseries\sffamily}

%\usepackage{caption}
\usepackage{chngcntr} % This is to add section number before figure.
\counterwithin{table}{section}

\usepackage{lipsum} % fir dummy text in tables

\begin{document}

\listoftables

\chapter{My Chapter 1}
\section{first}
\begin{table}[ht]
\centering
\caption{Standard table}
\begin{tabular}{cc}
\hline
1   &   2   \\
\hline
\end{tabular}
\label{tab:standardtable}
\end{table}
Table \ref{tab:standardtable} is standard table in \verb+table+ float. 

\begin{longtblr}[
    caption = {Sample table with tabularray},
      label = {tab:longtblr},
    ]{hlines, vlines,
      colspec = {X[c,m] X[c,m]},
      rowhead = 1,
     }
    Number 1 & Number 2 \\
    \lipsum[66] & \lipsum[66]   \\
    \lipsum[66] & \lipsum[66]   \\
    \lipsum[66] & \lipsum[66]   \\
    \lipsum[66] & \lipsum[66]   \\
\end{longtblr}
Table \ref{tab:longtblr} is a long table created with \verb+longtblr+

\chapter{My Chapter 2}

\begin{longtblr}[
    caption = {Sample table with tabularray},
      label = {tab:longtblr-2},
    ]{hlines, vlines,
      colspec = {X[c,m] X[c,m]},
      rowhead = 1,
     }
    Number 1 & Number 2 \\
    \lipsum[66] & \lipsum[66]   \\
    \lipsum[66] & \lipsum[66]   \\
\end{longtblr}
Table \ref{tab:longtblr-2} is a long table created with \verb+longtblr+ in placed before first section in chapter. Observe \verb+0+ in caption as well in reference number.

\lipsum[1]

\section{First section in the second chapter}
    \begin{table}[ht]
\begin{talltblr}[
    caption = {Sample of \texttt{talltblr} table with two lines long caption text which will not shown in the list of figures (LoF).},
      entry = {Short caption of \texttt{talltblr} table.},
      label = {tab:talltblr},
note{a} = {description of the first table note},
note{b} = {description of the second table note},
    ]{hlines, vlines,
      colspec = {X[c,m] X[c,m]},
      row{1} = {font=\bfseries},
     }
Category\TblrNote{a} 
                & Reference\TblrNote{a}\\
    \lipsum[66] & \lipsum[66]   \\
    \lipsum[66] & \lipsum[66]   \\
\end{talltblr}
    \end{table}
Table \ref{tab:talltblr} is a table created with \verb+tallgtblr+ placed in the first section in the second chapter. It is inserted in \verb+figure+ float, but caption is written as part of \verb+tallgtblr+ code.

\end{document}

figure它给出了预期结果:在 LoT(ListofTables)中,环境中的标准表和表的列表相等longtblr

在此处输入图片描述

编辑: 如您所见,两者在表格编号前都没有标签名称。这是标准功能。如果您喜欢在数字前添加标签名称,那么您需要在文档序言中添加以下代码行:

\usepackage{tocloft}
  \cftsetindents{table}{0em}{6em}
  \renewcommand\cfttabpresnum{Table }

在我的 MWE 中考虑它们可以得出:

在此处输入图片描述

相关内容