LoT 中的长表标题与 Table\Tabular 的行为方式不同

LoT 中的长表标题与 Table\Tabular 的行为方式不同

我正在使用提供给我的一个类文件,它有助于格式化大学研究论文。除其他外,它会在将表格标题列入 LoT 之前修改表格标题列表。通常,表格序列号,后跟表格标题,后跟虚线,最后是页码,构成行条目。例如:

 1         Caption of table one . . . . . . . .   1

类文件中的某些代码生成了如下内容:

 Table 1:  Caption of table one . . . . . . . .   1

...这是理想的,只要使用“table”和“tabular”创建表,它就可以工作。但是,我有一些很长的表,所以我对它们使用了“longtable”。问题是修改 LoT(以及 LoF)行条目的代码不会对修改 longtable 序列号做任何事情,所以我最终得到以下结果:

 Table 1:  Caption of table one . . . . . . . .   1     % produced with the former method
 2         Caption of table two . . . . . . . .   1     % produced using 'longtable'

类文件中修改文本的具体代码位于文件的第 913-915 行。它看起来像这样(我将在后续文章中在更大的上下文中列出相同的代码片段;类文件非常大——不确定这里共享其内容的协议是什么):

 \patchcmd{\@caption}{\csname the#1\endcsname}{\csname fnum@#1\endcsname:}{}{}
 \renewcommand*\l@figure{\@dottedtocline{1}{1.5em}{4.5em}}     % default for 3rd arg: 2.3em
 \let\l@table\l@figure % as in article.cls

我读了提供给用户25260的答案https://tex.stackexchange.com/questions/96053/longtable-list-of-tables-caption-problem,但答案似乎不适合我的课程文件。我希望得到一些指导。顺便说一句...我不是 LaTeX 专家(实际上使用 ShareLaTeX)。MWE:

\documentclass{UCF_ETD}
\usepackage{times}
%\usepackage{graphicx}     used, but not needed for MWE
%\usepackage{gensymb}      used, but not needed for MWE
\usepackage{caption}
\usepackage{multirow}
\usepackage{longtable}
\usepackage{array}
\usepackage{booktabs}
%\usepackage[utf8]{inputenc}      used, but not needed for MWE
%\usepackage[round, sort]{natbib} used, but not needed for MWE

% new type of column
\newcolumntype{R}{>{\raggedright\arraybackslash}p{.2\textwidth}}

\begin{document}

  \frontmatter
  % applies roman numerals as page numbers

  %\tableofcontents
  \begin{tableofcontents}
  \end{tableofcontents}

  %\listoffigures
  \begin{listoffigures}
  \end{listoffigures}

  %\listoftables
  \begin{listoftables}
  \end{listoftables}

  \mainmatter
  % restarts page numbering with Arabic numbers

  \section{A Human Factors Approach to (Steering System) Design Requirements}
  In this sentence, we reference Table~\ref{table:biometrics}; the label "Limits for upper limb joint angles" is added to the LoT, prefixed with "Table ", and a colon appended to the table sequence number (which is 1).  And from this sentence, we reference Table~\ref{table:hwCitations}.  The table caption gets entered into the LoT, but only the table sequence number precedes the caption text.  The text, "Table " and the subsequent ":" don't make it in.

  \begin{table}[h!]
    \centering
    \caption{Limits for upper limb joint angles}
    \begin{tabular*}{0.9\textwidth}{@{\extracolsep{\fill}} l r r }
      \hline
      \sffamily Angle\quad & \sffamily Minimum value (degrees)(\(a_{min}\))\quad & \sffamily Maximum value (degrees)(\(a_{max}\)) \\
      \hline
      \(a_{1}\) & -90 & 135 \\
      \(a_{2}\) & -80 & 45 \\
      \(a_{3}\) & -100 & 25 \\
      \(a_{4}\) & -140 & 0 \\
      \(a_{5}\) & -140 & 0 \\
      \(a_{6}\) & 0 & 15 \\
      \(a_{7}\) & -180 & 0 \\
      \(a_{8}\) & -80 & 80 \\
      \(a_{9}\) & -25 & 50 \\
      \hline
    \end{tabular*}
    \label{table:biometrics}
  \end{table}

  \renewcommand{\baselinestretch}{1.0}
  \begin{longtable}[H]{ p{.70\textwidth} R r } 
    \caption{Really-long Listing of Literature}\\
    \toprule

    \sffamily Title & \sffamily Author, Year & \sffamily Ct \\ [0.5ex]
    \midrule
    \endfirsthead
    %\caption[]{(continued)}\\
    \toprule
    \sffamily Title & \sffamily Author, Year & \sffamily Ct \\ [0.5ex]
    \midrule
    \endhead
    \sffamily\itshape\small A Control-Theoretic Approach to Adaptive Physiological Games & \sffamily\small Parnandi \& Gutierrez-Osuna, 2013 & \sffamily\small 10 \\
    \sffamily\itshape\small A Novel Virtual Reality Driving Environment for Autism Intervention & \sffamily\small Bian et al., 2013 & \sffamily\small 9 \\
    \sffamily\itshape\small An Experimental Space for Conducting Controlled Driving Behavior Studies Based on a Multiuser Networked 3D Virtual Environment and the Scenario Markup Language & \sffamily\small Gajananan et al., 2013 & \sffamily\small 11 \\
    \sffamily\itshape\small Design of a Virtual Reality Driving Environment to Assess Performance of Teenagers with ASD & \sffamily\small Wade et al., 2014 & \sffamily\small 6 \\
    \sffamily\itshape\small Evaluating Multimodal Driver Displays of Varying Urgency & \sffamily\small Politis et al., 2013 & \sffamily\small 14 \\
    \sffamily\itshape\small Gesturing on the Steering Wheel: A User-Elicited Taxonomy & \sffamily\small Angelini et al., 2014 & \sffamily\small 3 \\
    \sffamily\itshape\small Real-time Drunkenness Analysis in a Realistic Car Simulation & \sffamily\small Robinel \& Puzenat, 2012 & \sffamily\small 2 \\

    \bottomrule
    \label{table:hwCitations}
  \end{longtable}
  \renewcommand{\baselinestretch}{1.6}

\end{document}

额外加分:在整理这个 MWE 时,我注意到表格标题和每个表格顶部水平线之间的垂直距离略有不同。我不明白为什么;如果你明白,请加入讨论。谢谢。

答案1

caption 包实现了\captionof{<caption type>}{caption text}宏,该宏也可在capt-of包中使用。您可以使用此宏在浮点数之外创建标题,在本例中是在环境之外longtable。对 MWE 的唯一更改是删除该环境 add\caption{Really-long Listing of Literature}\\之后begin{longtable}和之前的行\captionof{table}{Really-long Listing of Literature}

这将生成所需的表格列表:

在此处输入图片描述

标题行间距的差异是由于\hline在第一个表中使用了规则,但在第二个表中使用了toprule和,midline以及\\ [0.5ex]在第二个表的第一行末尾添加了toprulemidrule添加额外的空间。

我还尝试清理其他一些东西。如果您想要无衬线字体的表格,只需\sffamily在表格开头发出一次开关即可。要使第二个表格的第 1 列以斜体显示,请使用。我取了列之间的填充并将单位移至第二个标题行以使表格更紧凑。我使用带有选项的after loading 包\begin{longtable}[H]{>{\itshape}p{.70\textwidth} R r }为行添加了阴影 。\rowcolors{2}{gray!25!white}{}xcolortable

如果您想使用“表示撇号,则需要在序言中通过加载csquotes包并添加来声明\MakeOuterQuote{"}

您的表格现在看起来像这样,并且文本有正确的开始和结束引号:

在此处输入图片描述

这是您更新的 MWE:

\documentclass{UCF_ETD}
%\documentclass{book}
\usepackage{times}
%\usepackage{graphicx}     used, but not needed for MWE
%\usepackage{gensymb}      used, but not needed for MWE
\usepackage{longtable} % Must be before ltcaption
\usepackage{caption}
\usepackage{multirow}
\usepackage{csquotes} %<-- for correct apostrophes
\MakeOuterQuote{"}
\usepackage{array}
\usepackage[table]{xcolor}
\usepackage{booktabs}
%\usepackage[utf8]{inputenc}      used, but not needed for MWE
%\usepackage[round, sort]{natbib} used, but not needed for MWE

% new type of column
\newcolumntype{R}{>{\raggedright\arraybackslash}p{.2\textwidth}}

\begin{document}

  \frontmatter
  % applies roman numerals as page numbers

  %\tableofcontents
  \begin{tableofcontents}
  \end{tableofcontents}

  %\listoffigures
  \begin{listoffigures}
  \end{listoffigures}

  %\listoftables
  \begin{listoftables}
  \end{listoftables}

  \mainmatter
  % restarts page numbering with Arabic numbers

  \section{A Human Factors Approach to (Steering System) Design Requirements}
  In this sentence, we reference Table~\ref{table:biometrics}; the label "Limits for upper limb joint angles" is added to the LoT, prefixed with "Table ", and a colon appended to the table sequence number (which is 1).  And from this sentence, we reference Table~\ref{table:hwCitations}.  The table caption gets entered into the LoT, but only the table sequence number precedes the caption text.  The text, "Table " and the subsequent ":" don't make it in.

  \renewcommand{\baselinestretch}{1.0}
%  \renewcommand{\arraystretch}{1.0}
  \begin{table}[h!]
    \centering
    \caption{Limits for upper limb joint angles}
    \sffamily
    \rowcolors{2}{gray!25!white}{}
%    \begin{tabular}{0.9\textwidth}{@{\extracolsep{\fill}} l r r }
      \begin{tabular}{l r r }
      \toprule % replaced \hline
       Angle &  Minimum value & Maximum value  \\ 
             & (degrees)(\(a_{min}\)) & (degrees)(\(a_{max}\)) \\
      \midrule % replaced \hline
      \(a_{1}\) & -90 & 135 \\
      \(a_{2}\) & -80 & 45 \\
      \(a_{3}\) & -100 & 25 \\
      \(a_{4}\) & -140 & 0 \\
      \(a_{5}\) & -140 & 0 \\
      \(a_{6}\) & 0 & 15 \\
      \(a_{7}\) & -180 & 0 \\
      \(a_{8}\) & -80 & 80 \\
      \(a_{9}\) & -25 & 50 \\
      \bottomrule % replaced \hline
    \end{tabular}
    \label{table:biometrics}
  \end{table}

  \renewcommand{\baselinestretch}{1.0}
%  \renewcommand{\arraystretch}{1.0}
  \captionof{table}{Really-long Listing of Literature}
  \sffamily
  \rowcolors{2}{gray!25!white}{}
  \begin{longtable}[H]{>{\itshape}p{.70\textwidth} R r } 
    \toprule
     {\normalfont\sffamily Title} &  Author, Year & Ct \\ %[0.5ex]
    \midrule
    \endhead 
    %\caption[]{(continued)}\\
%    \toprule
%    \sffamily Title & \sffamily Author, Year & \sffamily Ct \\ %[0.5ex]
%    \midrule
%    \endhead
     A Control-Theoretic Approach to Adaptive Physiological Games &  Parnandi \& Gutierrez-Osuna, 2013 &  10 \\
     A Novel Virtual Reality Driving Environment for Autism Intervention &  Bian et al., 2013 &  9 \\
     An Experimental Space for Conducting Controlled Driving Behavior Studies Based on a Multiuser Networked 3D Virtual Environment and the Scenario Markup Language &  Gajananan et al., 2013 &  11 \\
     Design of a Virtual Reality Driving Environment to Assess Performance of Teenagers with ASD &  Wade et al., 2014 &  6 \\
     Evaluating Multimodal Driver Displays of Varying Urgency &  Politis et al., 2013 &  14 \\
     Gesturing on the Steering Wheel: A User-Elicited Taxonomy &  Angelini et al., 2014 &  3 \\
     Real-time Drunkenness Analysis in a Realistic Car Simulation &  Robinel \& Puzenat, 2012 &  2 \\
    \bottomrule
    \label{table:hwCitations}
  \end{longtable}
  \renewcommand{\baselinestretch}{1.6}

\end{document}

相关内容