Graphics, Figures & TablesList of Tables is clear

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
petmat
Posts: 3
Joined: Wed Jul 22, 2015 2:21 pm

List of Tables is clear

Post by petmat »

Hello, I have a problem with \listoftables command. After I write in my document:

Code: Select all

\addcontentsline{toc}{chapter}{List of Tables}
\listoftables
there appears only List of Tables in the content and inside the document there a page with headline List of Tables, but otherwise the page is clear and no tables are listed. My tables includes \caption[short name]{long name}
inside the \begin{table}..\end{table}.
I don't know what I am doing wrong, anything like \cleardoublepage didn't help. The same happened for the List of Figures.
Thank you for any help!
Petra
Last edited by cgnieder on Sun Jul 26, 2015 1:18 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

List of Tables is clear

Post by Johannes_B »

Hi and welcome,

with the amount of information given, it is really hard to take even a guess. Please try to prepare a minimal working example and post it here. The cause will be obvious for the helpers here.

Remember, you always need to LaTeX runs to make any changes appear in toc,lof, and lot.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
petmat
Posts: 3
Joined: Wed Jul 22, 2015 2:21 pm

List of Tables is clear

Post by petmat »

Yes, sure, so this is how my document looks like:

Code: Select all

\documentclass[12pt,a4paper]{report}
\usepackage[latin2]{inputenc}
\usepackage{graphicx}
\usepackage{amsthm}
\usepackage{amsmath} %for aligned environment
\usepackage{longtable} % for abbreviations formating
\usepackage{verbatim} % for comment environment
\usepackage{listings} %for Attachments - code
\usepackage{amssymb} %for cross sign
\usepackage{float} %keep figure in fixes place
\usepackage{bm} %for bold in math mode
\usepackage[ps2pdf,unicode]{hyperref}
 
\def\chapwithtoc#1                  {
\chapter*{#1}
\addcontentsline{toc}{chapter}{#1}  }

\begin{document}
\openright
\pagestyle{plain}
\setcounter{page}{1}
\tableofcontents

\include{preface}
\include{chap1}   %here are the tables

\addcontentsline{toc}{chapter}{List of Tables}
\listoftables

\openright
\end{document}
and this is an example of one of my table in chapter 1:

Code: Select all

\begin{table}
 \centering
 \caption[AIM analysis]{AIM analysis of electron density}
 \begin{tabular}{|p{2.3cm}||p{1.9cm}|p{1.9cm}|p{2.2cm}|p{1.5cm}|}
  \hline
  Complex & Cl/O(OH) & O(H$_2$O) /N7(G) & N(Y) & N(NH$_3$)\\[2mm] 
   \hline \hline
 \multicolumn{5}{|p{9.5cm}|}{Reactants}\\ \hline    
  DDP-Cl            &8,38  &8,47  &11,27$^a$ &12,48\\
  DDP-OH            &12,46 &8,77  &10,41$^a$ &12,32\\ \hline
 Pt-Tz-OH       &13,11   &10,53  &11,47  &11,97\\ \hline
\end{tabular}    
\label{table:aimPt_isol}
\end{table}
As I said, the List of Tables appears in the content and there is a page with headline List of Tables, but the tables are not listed on the page.
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

List of Tables is clear

Post by Johannes_B »

Unfortunately, that is not a minimal working example as described in the link i gave above. Pasting the code and and removing the unknown openright i don't get any strange behaviour. I get a list of figures including the right entry.


Hint: Click on open in writelatex below to see what i see.

Code: Select all

% arara: latex
% arara: latex
% arara: dvips
% arara: ps2pdf
\documentclass[12pt,a4paper]{report}
%\usepackage[latin2]{inputenc}
\usepackage{graphicx}
\usepackage{amsthm}
\usepackage{amsmath} %for aligned environment
\usepackage{longtable} % for abbreviations formating
\usepackage{verbatim} % for comment environment
\usepackage{listings} %for Attachments - code
\usepackage{amssymb} %for cross sign
\usepackage{float} %keep figure in fixes place
\usepackage{bm} %for bold in math mode
\usepackage[%ps2pdf,%commented when using the online compiler
unicode]{hyperref}

\def\chapwithtoc#1                  {
	\chapter*{#1}
	\addcontentsline{toc}{chapter}{#1}  }

	\begin{document}
%	\openright%undefined control sequence
	\pagestyle{plain}
	\setcounter{page}{1}
	\tableofcontents

%	\include{preface}
	%\include{chap1}   %here are the tables
	\chapter{walzing wombat}
	\begin{table}
		\centering
		\caption[AIM analysis]{AIM analysis of electron density}
		\begin{tabular}{|p{2.3cm}||p{1.9cm}|p{1.9cm}|p{2.2cm}|p{1.5cm}|}
			\hline
			Complex & Cl/O(OH) & O(H$_2$O) /N7(G) & N(Y) & N(NH$_3$)\\[2mm]
			\hline \hline
			\multicolumn{5}{|p{9.5cm}|}{Reactants}\\ \hline    
			DDP-Cl            &8,38  &8,47  &11,27$^a$ &12,48\\
			DDP-OH            &12,46 &8,77  &10,41$^a$ &12,32\\ \hline
			Pt-Tz-OH       &13,11   &10,53  &11,47  &11,97\\ \hline
		\end{tabular}    
		\label{table:aimPt_isol}
	\end{table}

	\addcontentsline{toc}{chapter}{List of Tables}
	\listoftables

%	\openright
	\end{document}
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
petmat
Posts: 3
Joined: Wed Jul 22, 2015 2:21 pm

Re: List of Tables is clear

Post by petmat »

So, I have discovered the problem, after the \listoftables command I have command \include{attachments}. When I comment this and copy the content of the attachments into the main document, the tables are suddenly listed in the List of Tables page. I don't know why that matters, but, at least, it works.
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

List of Tables is clear

Post by cgnieder »

I don't really understand the question but i take it from the thread that the main problem is solved, anyway?

I have some other suggestions for possible improvements, though:

You probably want to use this:

Code: Select all

\clearpage
\phantomsection
\addcontentsline{toc}{chapter}{List of Tables}
\listoftables
The \clearpage and the \phantomsection ensure that the hyperlink from the toc actually point to the right place in the document and not to the page before the list of tables.

Similarly the definition of \chapwithtoc:

Code: Select all

\newcommand*\chapwithtoc[1]{%
  \chapter*{#1}
  \phantomsection
  \addcontentsline{toc}{chapter}{#1}
}
BTW: \def is a low-level TeX macro and if possible should be avoided in a LaTeX document. It's better to use LaTeX's \newcommand instead.

You also might be interested in the chemformula package for writing chemical formulae like water: \ch{H2O}.

Last but not least I also suggest taking a look at the siunitx package which not only is good for taking care of SI units but also for alignment of numbers in a table.

Personally I'd probably typeset the table something like this:

Code: Select all

\documentclass[12pt,a4paper]{report}
\usepackage[utf8]{inputenc}

\usepackage{array}
\usepackage{booktabs}

\usepackage{chemformula}
\usepackage{siunitx}

\newcommand*\tnote[1]{\textsuperscript{\textit{#1}}}

\begin{document}

\begin{table}
  \centering
  \caption[AIM analysis]{AIM analysis of electron density. (\tnote{a} some
    notes on these values\ldots)}
  \label{table:aimPt_isol}
  \begin{tabular}{
      l
      *{2}{S[table-format=2.2]}
      S[table-format=2.2,table-space-text-post={\tnote{a}}]
      S[table-format=2.2]
    }
    \toprule
      Complex & {\ch{Cl/O(OH)}} & {\ch{O(H2O)/N7(G)}} & {\ch{N(Y)}} & {\ch{N(NH3)}} \\
    \midrule
      Reactants \\
    \cmidrule{1-1}
      \ch{DDP-Cl}   &  8,38 &  8,47 & 11,27\tnote{a} & 12,48 \\
      \ch{DDP-OH}   & 12,46 &  8,77 & 10,41\tnote{a} & 12,32 \\
      \ch{Pt-Tz-OH} & 13,11 & 10,53 & 11,47          & 11,97 \\
    \bottomrule
  \end{tabular}
\end{table}

\end{document}
table.png
table.png (28.78 KiB) Viewed 9739 times
Regards
site moderator & package author
Post Reply