3

I am writing a MS dissertation, and using a long table in my thesis. I have a problem related with the caption of the long table in list of tables(LoT). Table 4.1 which is seen below, is a long table and not convenient for the thesis format for LoT. I want long table to be in the same format like other tables in LoT. I solved the same problem for normal tables and figures by setting \usepackage[caption=false]{subfig}. However, it did not work for long table.

Table 3.5. Caption.......

4.1 Caption........

Table 4.2. Caption......

Table 4.3. Caption......

The long table is the following. Thanks in advance for any help.

\begin{center}
\begin{longtable}{ | c | p{3cm} | c | c | c |}
\caption{Basic properties of sensors during deployment.}  \label{table:basic-property-deployment}
\\  \hline
    \textbf{Sensors} & \textbf{Location} & \textbf{Threshold} & \textbf{Base Station} & \textbf{Resistance}\\ [6pt]
    \hline
    \endfirsthead
    \multicolumn{5}{c}%
   % \bigskip 
    {\tablename\ \thetable\ . Basic properties of sensors during deployment} \\
    \hline
     \textbf{Sensors} & \textbf{Location} & \textbf{Threshold} & \textbf{Base Station} & \textbf{Resistance}\\ [6pt]
     \hline
     \endhead
     \hline \multicolumn{5}{r}{\textit{Continued on next page}} \\
     \endfoot
     \hline
     \endlastfoot

     ROWS


\end{longtable}
\end{center}

2 Answers 2

4

It always helps if you post a complete document showing all packages loaded, but as a guess longtable toc is written by

\def\LT@c@ption#1[#2]#3{%
  \LT@makecaption#1\fnum@table{#3}%
  \def\@tempa{#2}%
  \ifx\@tempa\@empty\else
     {\let\\\space
     \addcontentsline{lot}{table}{\protect\numberline{\thetable}{#2}}}%
  \fi}

So if you had

\makeatletter
\def\LT@c@ption#1[#2]#3{%
  \LT@makecaption#1\fnum@table{#3}%
  \def\@tempa{#2}%
  \ifx\@tempa\@empty\else
     {\let\\\space
     \addcontentsline{lot}{table}{\protect\numberline{Table \thetable.}{#2}}}%
  \fi}
\makeatother

Then Table would appear in the toc (or use whatever other format your caption style is using in \addcontentsline)

5
  • Thank you so much David, you saved my day:)) Your guess is right, it works:) Now another problem occurs, I need a new line between the long table and the subsequent table in LoT. Since, I do not have enough reputation to send an image, I try to describe it below, sorry for that.
    – user25260
    Jan 30, 2013 at 21:36
  • You can use the image upload button but then delete (just) the ! from the generated markup, that makes a link to the image and someone with edit rights will put the ! back Jan 30, 2013 at 21:40
  • Ok. I think I put the image, actually it does not seem as a serious problem, however I need space between the long table and the subsequent table in LoT as it can be seen in the image. When I insert new lines in the code you supplied, the dots disappears, and the page number is placed to the next line which I do not want. I need just a space between the long table and the subsequent one in LoT. [enter image description here][1] [1]: i.stack.imgur.com/iHDj5.png
    – user25260
    Jan 30, 2013 at 22:03
  • 1
    Do you have any idea about the spacing problem between the long table entry and next table entry in LoT?
    – user25260
    Jan 31, 2013 at 12:31
  • @DavidCarlisle I have seen this same spacing issue. A normal table caption (defined in the documentclass) adds an \addvspace that the longtable caption does not. So it seems longtable is somehow overriding the documentclass's caption command (which produces this \addvspace). Oh I just noticed, the caption package is loaded.
    – Alan
    Jul 31, 2015 at 22:00
0

You can use the below code in the prelude of your .tex file. It will both correct the captions of longtables and lines in the list of tables. (based on the answer of David Carlisle, of course).

\setlength\LTcapwidth{\textwidth}

\makeatletter
  \def\LT@makecaption#1#2#3{%
    \LT@mcol\LT@cols c{\hbox to\z@{\hss\parbox[t]\LTcapwidth{%
    \vskip\abovecaptionskip
    \centering{
      \sbox\@tempboxa{#1{#2 }#3}%
      \ifdim\wd\@tempboxa>\hsize
        #1{#2. }#3%
      \else
        \hbox to\hsize{\hfil\box\@tempboxa\hfil}%
      \fi
      \endgraf\vskip\baselineskip}}%
    \hss}}}
\makeatother

\makeatletter
  \def\LT@c@ption#1[#2]#3{%
    \LT@makecaption#1\fnum@table{#3}%
    \def\@tempa{#2}%
    \ifx\@tempa\@empty\else
    {\let\\\space
      \addcontentsline{lot}{table}{\protect\numberline{Table \thetable.}{\ignorespaces #2}\vspace\baselineskip}%
    }%
    \fi
  }
\makeatother
2
  • Welcome to TeX.SX! Does this do differently from the code in the other answer? Note that you're misusing \centering, which does nothing at all inside an \hbox, besides not being a command with an argument.
    – egreg
    Sep 4, 2016 at 22:14
  • thanks :) it converts the default caption format (Table 2.3: Lorem) to (Table 2.3. Lorem) and solve the spacing problem between the long table entry and next table entry in LoT. \centering is needed for captions on the tables to be centered, if not put the captions for tables in the text shift to the left in my case. Sep 5, 2016 at 11:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .