4

I was working with LaTex and wanted to get the following form output for \listoftables tab space is a particular amount of gap. Can any body help me in doing this in following format. I've tried it but it has yielded no result like the needed ones.

LIST OF TABLES

Chapter 1

Table 1.1   {tab space}            Name of Table     {tab space}                   Page Number

Table 1.2   {tab space}            Name of Table     {tab space}                   Page Number

Chapter 2

Table 2.1   {tab space}            Name of Table     {tab space}                   Page Number
  • Please provide a bit more information about your document setup. E.g., which document class do you use, are you loading a package such as tocloft that simplifies the creation of Tables of Contents (and Lists of Tables). Can every chapter be assumed to contain at least one table? – Mico Apr 1 '14 at 15:05
  • The convenience of adding a vertical space (default is done using \addvspace{10\p@}) is that it doesn't affect a chapter where you do not have any tables (floats) in it. With an automated approach you would need to count the number of floats in a chapter and conditionally place the Chapter X heading. Alternatively, how do you plan on handling chapters without any floats? – Werner Apr 1 '14 at 15:08
  • I am using Report type and no extra package. chapters may or may not have a table. its just that. – Shivam Dhoot Apr 1 '14 at 15:09
  • I am using Report type and no extra package with the chapters may or may not have a table. Its just it – Shivam Dhoot Apr 1 '14 at 15:15
  • Related: tex.stackexchange.com/questions/167847/… – egreg Apr 1 '14 at 16:53
3

You could achieve your objective by (a) using a modified \chapter command for those chapters that contain tables (the modifications mainly consist of writing "Chapter <num>" to the file \jobname.lot) and (b) employing the tocloft package to insert the string "Table " right before the table number in the list of tables.

enter image description here

\documentclass{report}
\usepackage{tocloft}
  \cftsetindents{table}{0em}{6em}
  \renewcommand\cfttabpresnum{Table } % prefix "Table " to table number
\newcommand{\tchapter}[1]{%
  \chapter{#1}
  \addtocontents{lot}{Chapter \thechapter} % write 
  \addtocontents{lot}{\medskip} % choose vertical spacing to suit your needs
}
\begin{document}\pagestyle{empty}
\tableofcontents
\listoftables
\tchapter{First chapter}

\begin{table}[th!] \caption{First} \centering u \end{table}
\begin{table}[h]   \caption{Second}\centering v \end{table}
\begin{table}[h]   \caption{Third} \centering w \end{table}

\tchapter{Second chapter}
\begin{table}[th!] \caption{Fourth}\centering x \end{table}
\begin{table}[h]   \caption{Fifth} \centering y \end{table}
\begin{table}[h]   \caption{Sixth} \centering z \end{table}

\chapter{Third chapter} % no tables in this chapter, so don't use \tchapter

\tchapter{Fourth chapter}
\begin{table}[th!] \caption{Seventh}\centering x \end{table}
\begin{table}[h]   \caption{Eighth} \centering y \end{table}
\begin{table}[h]   \caption{Ninth} \centering z \end{table}

\end{document} 
4

Like this?

enter image description here

Code:

\documentclass{report}
\usepackage{tocloft}
\usepackage{etoolbox}
\makeatletter
\patchcmd{\@chapter}
  {\addtocontents{lot}{\protect\addvspace{10\p@}}}
  {\addtocontents{lot}{\par\protect\addvspace{10\p@}}
   \addtocontents{lot}{\textbf{#1}}
   \addtocontents{lot}{\vspace{5pt}}}
  {}
  {}
\makeatother

\setlength{\cfttabindent}{0cm}
\renewcommand{\cfttabdotsep}{\cftnodots}
\renewcommand\cfttabpresnum{\tablename~}
\setlength\cfttabnumwidth{5cm}

\begin{document}

\listoftables

\chapter{Chapter 1}
\begin{table}
\caption{Name of table}
\end{table}
\begin{table}
\caption{Name of table}
\end{table}

\chapter{Chapter 2}
\begin{table}
\caption{Name of table}
\end{table}

\end{document} 

I've patched the \@chapter command so to insert the name of the chapter in the LoT

\makeatletter
\patchcmd{\@chapter}
  {\addtocontents{lot}{\protect\addvspace{10\p@}}}
  {\addtocontents{lot}{\par\protect\addvspace{10\p@}}
   \addtocontents{lot}{\textbf{#1}}
   \addtocontents{lot}{\vspace{5pt}}}
  {}
  {}
\makeatother

and adjusted the parameters for tables with the help of tocloft commands

\setlength{\cfttabindent}{0cm}
\renewcommand{\cfttabdotsep}{\cftnodots}
\renewcommand\cfttabpresnum{\tablename~}
\setlength\cfttabnumwidth{5cm}

Adjust the last lenght from 5cm to whatever you need.

  • Can your approach deal with chapters that don't contain tables? The OP has indicated in a comment that a given chapter may or may not contain tables. – Mico Apr 1 '14 at 16:15
  • @Mico It's not clear to me whether the OP wants to show chapters without tables or not. – karlkoeller Apr 1 '14 at 17:21
  • karlkoeller sir i don't want to show chapters which don't have tables but i will do that now from tocloft package study but Really Thanks to you. You helped me a lot and Mico Sir thanks for your help too sir. You guies are great. I don't know when i'll be this much smooth in LaTex and life. – Shivam Dhoot Apr 2 '14 at 6:20

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.