LaTeX forum ⇒ Graphics, Figures & TablesList of Tables is clear

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

List of Tables is clear

Postby petmat » Wed Jul 22, 2015 2:48 pm

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

  1. \addcontentsline{toc}{chapter}{List of Tables}
  2. \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.
Reason: code markup added

Tags:

User avatar
Johannes_B
Site Moderator
Posts: 4044
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Wed Jul 22, 2015 4:20 pm

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

Postby petmat » Wed Jul 22, 2015 8:58 pm

Yes, sure, so this is how my document looks like:
  1. \documentclass[12pt,a4paper]{report}
  2. \usepackage[latin2]{inputenc}
  3. \usepackage{graphicx}
  4. \usepackage{amsthm}
  5. \usepackage{amsmath} %for aligned environment
  6. \usepackage{longtable} % for abbreviations formating
  7. \usepackage{verbatim} % for comment environment
  8. \usepackage{listings} %for Attachments - code
  9. \usepackage{amssymb} %for cross sign
  10. \usepackage{float} %keep figure in fixes place
  11. \usepackage{bm} %for bold in math mode
  12. \usepackage[ps2pdf,unicode]{hyperref}
  13.  
  14. \def\chapwithtoc#1 {
  15. \chapter*{#1}
  16. \addcontentsline{toc}{chapter}{#1} }
  17.  
  18. \begin{document}
  19. \openright
  20. \pagestyle{plain}
  21. \setcounter{page}{1}
  22. \tableofcontents
  23.  
  24. \include{preface}
  25. \include{chap1} %here are the tables
  26.  
  27. \addcontentsline{toc}{chapter}{List of Tables}
  28. \listoftables
  29.  
  30. \openright
  31. \end{document}


and this is an example of one of my table in chapter 1:
  1. \begin{table}
  2. \centering
  3. \caption[AIM analysis]{AIM analysis of electron density}
  4. \begin{tabular}{|p{2.3cm}||p{1.9cm}|p{1.9cm}|p{2.2cm}|p{1.5cm}|}
  5. \hline
  6. Complex & Cl/O(OH) & O(H$_2$O) /N7(G) & N(Y) & N(NH$_3$)\\[2mm]
  7. \hline \hline
  8. \multicolumn{5}{|p{9.5cm}|}{Reactants}\\ \hline
  9. DDP-Cl &8,38 &8,47 &11,27$^a$ &12,48\\
  10. DDP-OH &12,46 &8,77 &10,41$^a$ &12,32\\ \hline
  11. Pt-Tz-OH &13,11 &10,53 &11,47 &11,97\\ \hline
  12. \end{tabular}
  13. \label{table:aimPt_isol}
  14. \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: 4044
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Thu Jul 23, 2015 10:51 am

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.
  1. % arara: latex
  2. % arara: latex
  3. % arara: dvips
  4. % arara: ps2pdf
  5. \documentclass[12pt,a4paper]{report}
  6. %\usepackage[latin2]{inputenc}
  7. \usepackage{graphicx}
  8. \usepackage{amsthm}
  9. \usepackage{amsmath} %for aligned environment
  10. \usepackage{longtable} % for abbreviations formating
  11. \usepackage{verbatim} % for comment environment
  12. \usepackage{listings} %for Attachments - code
  13. \usepackage{amssymb} %for cross sign
  14. \usepackage{float} %keep figure in fixes place
  15. \usepackage{bm} %for bold in math mode
  16. \usepackage[%ps2pdf,%commented when using the online compiler
  17. unicode]{hyperref}
  18.  
  19. \def\chapwithtoc#1 {
  20. \chapter*{#1}
  21. \addcontentsline{toc}{chapter}{#1} }
  22.  
  23. \begin{document}
  24. % \openright%undefined control sequence
  25. \pagestyle{plain}
  26. \setcounter{page}{1}
  27. \tableofcontents
  28.  
  29. % \include{preface}
  30. %\include{chap1} %here are the tables
  31. \chapter{walzing wombat}
  32. \begin{table}
  33. \centering
  34. \caption[AIM analysis]{AIM analysis of electron density}
  35. \begin{tabular}{|p{2.3cm}||p{1.9cm}|p{1.9cm}|p{2.2cm}|p{1.5cm}|}
  36. \hline
  37. Complex & Cl/O(OH) & O(H$_2$O) /N7(G) & N(Y) & N(NH$_3$)\\[2mm]
  38. \hline \hline
  39. \multicolumn{5}{|p{9.5cm}|}{Reactants}\\ \hline
  40. DDP-Cl &8,38 &8,47 &11,27$^a$ &12,48\\
  41. DDP-OH &12,46 &8,77 &10,41$^a$ &12,32\\ \hline
  42. Pt-Tz-OH &13,11 &10,53 &11,47 &11,97\\ \hline
  43. \end{tabular}
  44. \label{table:aimPt_isol}
  45. \end{table}
  46.  
  47. \addcontentsline{toc}{chapter}{List of Tables}
  48. \listoftables
  49.  
  50. % \openright
  51. \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

Postby petmat » Thu Jul 23, 2015 3:47 pm

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: 1988
Joined: Sat Apr 16, 2011 7:27 pm

Postby cgnieder » Sun Jul 26, 2015 2:04 pm

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:
  1. \clearpage
  2. \phantomsection
  3. \addcontentsline{toc}{chapter}{List of Tables}
  4. \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:
  1. \newcommand*\chapwithtoc[1]{%
  2. \chapter*{#1}
  3. \phantomsection
  4. \addcontentsline{toc}{chapter}{#1}
  5. }


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:

  1. \documentclass[12pt,a4paper]{report}
  2. \usepackage[utf8]{inputenc}
  3.  
  4. \usepackage{array}
  5. \usepackage{booktabs}
  6.  
  7. \usepackage{chemformula}
  8. \usepackage{siunitx}
  9.  
  10. \newcommand*\tnote[1]{\textsuperscript{\textit{#1}}}
  11.  
  12. \begin{document}
  13.  
  14. \begin{table}
  15. \centering
  16. \caption[AIM analysis]{AIM analysis of electron density. (\tnote{a} some
  17. notes on these values\ldots)}
  18. \label{table:aimPt_isol}
  19. \begin{tabular}{
  20. l
  21. *{2}{S[table-format=2.2]}
  22. S[table-format=2.2,table-space-text-post={\tnote{a}}]
  23. S[table-format=2.2]
  24. }
  25. \toprule
  26. Complex & {\ch{Cl/O(OH)}} & {\ch{O(H2O)/N7(G)}} & {\ch{N(Y)}} & {\ch{N(NH3)}} \\
  27. \midrule
  28. Reactants \\
  29. \cmidrule{1-1}
  30. \ch{DDP-Cl} & 8,38 & 8,47 & 11,27\tnote{a} & 12,48 \\
  31. \ch{DDP-OH} & 12,46 & 8,77 & 10,41\tnote{a} & 12,32 \\
  32. \ch{Pt-Tz-OH} & 13,11 & 10,53 & 11,47 & 11,97 \\
  33. \bottomrule
  34. \end{tabular}
  35. \end{table}
  36.  
  37. \end{document}


table.png
table.png (28.78 KiB) Viewed 3688 times


Regards
Clemens
------------------------------
chemmacros · chemformula · leadsheets · xsim


Return to “Graphics, Figures & Tables”

Who is online

Users browsing this forum: No registered users and 4 guests