2

I am using a class file that has been provided to me that helps format university research papers. Among other things, it modifies the listing-of-table captions before listing them into the LoT. Normally, the table sequence number, followed by the table caption, followed by a dotted line, and ending with a page number make up the line entry. For example:

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

Some code from the class file produces this instead:

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

...which is desired, and works as long as the table is created with 'table' and 'tabular'. However, I have some lengthy tables, so I am using 'longtable' for those. The problem is that the code that modifies the LoT (as well as LoF) line entry doesn't do anything to modify the longtable sequence number, so I end up with this:

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

The specific code in the class file that modifies the text is on lines 913-915 of the file. It looks like this (I will list the same snippet in a larger context in a follow-up post; the class file is very large--not sure what the protocol here is for sharing its contents):

 \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

I read the answer provided to user25260 at https://tex.stackexchange.com/questions/96053/longtable-list-of-tables-caption-problem, but the answer didn't seem to fit my class file. I would appreciate some guidance, here. BTW... I'm no expert with LaTeX (actually using ShareLaTeX). The 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}

And for bonus points: In putting together this MWE, I noticed the vertical distance between the table captions and the top horizontal rule of each table to differ a little. I don't understand why; if you do, please chime in. Thanks.

  • I need to post a larger portion of the class file; I read in another post that links to downloads aren't the preferred method, but her it is anyway: students.graduate.ucf.edu/WorkArea/DownloadAsset.aspx?id=1464. I'd like to post the portion of the class file that has anything at all to do with formatting the Toc, LoF, and LoT (a few hundred lines), but I'm not sure how I should do that. Should I just edit my original post and place it there inside of code tags? – Michael Xynidis Jul 17 '17 at 1:33
0

The caption package implements the \captionof{<caption type>}{caption text} macro, which is also available in the capt-of package. You can use this macro to create a caption outside a float, in this case outside the longtable environment. The only change to your MWE is to delete \caption{Really-long Listing of Literature}\\ after begin{longtable} and immediately before that environment add \captionof{table}{Really-long Listing of Literature}.

This produces the list of tables as required:

enter image description here

The difference in header row spacing is due to using \hline for the rules in the first table but toprule and midline in the second table as well as the addition of \\ [0.5ex] at the end of the first row of the second table. toprule and midrule add extra space.

I also tried to clean up a few other things. If you want the tables in sans serif, you only need to issue the switch \sffamily once at the beginning of the table. To get column 1 of the second table in italics use \begin{longtable}[H]{>{\itshape}p{.70\textwidth} R r }. I took at the padding between the columns and moved the units to the second header row to make the table more compact. I added shading to the rows using \rowcolors{2}{gray!25!white}{} after loading package xcolor with the table option.

If you want to use " for apostrophes, this needs to be declared in the preamble by loading the csquotes package and adding \MakeOuterQuote{"}.

Your tables now look like this and the text has correct opening and closing quotation marks:

enter image description here

This is your updated 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}
  • ...now if anybody can point me in the right direction about that the vertical distance between the table captions and the top horizontal rule being different between the two table types, I'd appreciate that too. – Michael Xynidis Jul 19 '17 at 23:16
  • @Michael I updated the answer to provide an explanation on the difference in row spacing of the table headers. – Ross Jul 20 '17 at 3:02
  • Thank you, @Ross. Your updates look great, and I'm going to use them as-is. I very-much appreciate your help, particularly when my own university--who provided the template--told me I was on my own. Thanks again. – Michael Xynidis Jul 21 '17 at 16:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.