You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

LaTeX:如何在保留longtblr环境的前提下添加表格标题?

如何在longtblr环境中为表格添加标题?

你遇到的问题核心在于:longtblr是tabularray包专属的长表格环境,它不兼容常规LaTeX的\caption命令,必须用它自带的参数来设置标题和标签。

下面是具体解决方法,附带修正后的完整代码:

关键修改点

  • 直接在longtblr的选项中添加caption={你的表格标题}和label={你的标签名}参数,无需单独写\caption或\label
  • 移除代码中重复加载的宏包(比如重复加载的caption、threeparttable、array),避免潜在冲突
  • 建议用booktabs的命令(\toprule、\midrule、\bottomrule)替代原始的\hline,表格排版更美观(可选)

修正后的完整代码

\documentclass[12pt]{article}
\usepackage{setspace}
\usepackage[labelfont=bf, justification=justified, singlelinecheck=false]{caption}
\usepackage{afterpage}
\usepackage{longtable}
\usepackage[flushleft]{threeparttable}
\usepackage{array,booktabs,makecell}
\usepackage{changepage}
\setcounter{tocdepth}{1}
\usepackage{fullpage}
\usepackage[T1]{fontenc}
\usepackage{natbib}
\doublespacing
\usepackage{titlesec}
\usepackage{url}
\setlength{\bibsep}{0.0pt plus 0.3ex}
\renewcommand\refname{References}
\usepackage[capposition=top]{floatrow}
\usepackage{lipsum}
\usepackage{pdflscape}

\usepackage{tabularray}

\begin{document}

\begin{landscape}
\begin{adjustwidth}{-1cm}{-1cm}
  \centering 
  \begin{longtblr}{
    colspec={X[l,0.5]X[l,0.5]X[c,1.5]X[l,0.5]X[l,2]},
    caption={受访者引用汇总表}, % 设置表格标题
    label={oa_tab:quotes},      % 设置表格标签
    rowhead=1                   % 可选:让表头在分页后每页重复显示
  }
  \toprule
  \textbf{Party} & \textbf{Person} & \textbf{Employment} & \textbf{Date} & \textbf{Quote}  \\ 
  \midrule
  A & John  & Works & May 2022 & "Some random text" \\ 
  \midrule
  B & Sam & Works & May 2021  & "Some random text" \\                 
  \bottomrule
  \end{longtblr}
\end{adjustwidth}
\end{landscape}

\end{document}

额外说明

  • 如果需要自定义标题格式,比如调整字体、对齐方式,可以在caption参数里嵌套格式命令,或者通过tabularray的caption-format参数设置
  • rowhead=1参数能让表头在分页后的每页顶部重复显示,适合长表格场景,建议加上

内容的提问来源于stack exchange,提问作者daviddupont

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.03 23:55:31