1

I am somewhat irritated about the numbering of tables. Unfortunately i dont have a MWE, i doubt the "error" will be seen in a short example (this is a thesis...). Also when moving things around the error will probably disappear on its own... still i'd rather know how to avoid it.

On to the issue, in the List Of Tables I have:

1. ... p.10
5. ... p. 52
2. ... p. 53
3. ... p. 54
4. ... p. 55

The List is actually correct in sorting according to page numbers. What irritates me is that the Table numbering is NOT distributed accordingly.

actually the Table numbering is in the order in which they appear in the tex document. Of course floats float, so why is the table numbering not adjusted?

I've read about \usepackage{fixltx2e} which fixes some similar errors - no luck. Also the flafter package doesnt seem to change anything. Admittedly i'm using a wild mix of longtable, sidewaystable, etc

Here is a MWE, well its rather long actually.

\documentclass[12pt,a4paper]{article}
\usepackage{amssymb,amsmath}
\usepackage[utf8]{inputenc}
\usepackage[T2A,T1]{fontenc} %for cyrillic support
\usepackage[russian,english]{babel}
\usepackage{tocloft}
\usepackage{longtable}
\usepackage{url}
\usepackage{scrextend}
\usepackage{float}
\usepackage{psfrag}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{graphicx}
\usepackage{rotating}
\usepackage{epstopdf}
\DeclareGraphicsExtensions{.pdf,.eps,.png,.jpg,.mps}
\usepackage{everyshi}
\usepackage[absolute]{textpos}
\usepackage{enumitem}
\usepackage{setspace}
\usepackage{subfig}
\usepackage{blindtext}

\mathsurround 1.5pt

\makeatletter
\renewcommand\@makefntext[1]{%
  \noindent\makebox[0.2em][r]{\@makefnmark}#1}
\makeatother

\makeatletter
\renewcommand*{\@seccntformat}[1]{%
 \csname the#1\endcsname.
}
\makeatother

\renewcommand{\cftsubsecindent}{1.5em}
\begin{document}
\tableofcontents
\newpage
\listoffigures
\addcontentsline{toc}{section}{List of Figures}
\listoftables
\addcontentsline{toc}{section}{List of Tables}
\newpage
\onehalfspacing

\section{Sec}
\blindtext
\section{Sec}
\blindtext

{
\def\legend{\multicolumn{6}{l}{\footnotesize Source:}\normalsize}

\begin{table}[ht!]\centering \caption{Means \label{meancompare}}
\begin{tabular}{l c c c c c }\hline\hline
\textbf{} & \textbf{All} & \textbf{asd} & \textbf{def} & \textbf{fgg} & \textbf{ccc}\\
\textbf{} &\text{Obs: 8038} & \text{Obs: 6590} & \text{Obs: 1014} & \text{Obs: 328} & \text{Obs: 106}\\\hline
Age & 40.515 & 40.299 & 41.560 & 40.650 & 44.028\\
HHsize & 5.308 & 5.2434 & 5.669 & 5.45 & 5.472\\
\legend
\end{tabular}
\end{table}
}

\blindtext

\section{Appendix}


\begin{sidewaystable}[htbp]\centering\small
 \caption{Estimation Results Model 1
\label{tabresult regress1}}
\begin{tabular}{l r @{} l c r @{} l c r @{} l c}
\hline\hline
test  &  0.096&***  & (0.020) &  0.103&l  & (0.020) &  0.102&*  & (0.020)\\
\end{tabular}
\end{sidewaystable}


\begin{table}[htbp]
\centering
 \caption{Estimation results}
\label{tabresult regress}
\begin{tabular}{l r @{} l c r @{} l c}
\hline\hline
test  &  0.096&*  & (0.020)\\
\hline
\end{tabular}
\end{table}



\begin{sidewaystable}[htbp]
\centering\small
 \caption{considered}
 \begin{tabular}{l|r r|r r|r r| r}
Total  & 5.729 & 71.27\% & 1.353 & 16.83\% & 956 & 11.89\% & 8.038\\
\end{tabular}
\end{sidewaystable}


{\footnotesize
\begin{longtable}{ p{3cm} p{5cm} r r r r}
\caption{Description and Summary of Variables}\\
\hline\hline
\textbf{Dependent Variable} & \textbf{Definition} & \textbf{Mean} & \textbf{SD} & \textbf{Min} & \textbf{Max}\\\hline\endfirsthead
\caption[]{(continued)}\\\hline\hline\textbf{Independent Variable} & \textbf{Definition} & \textbf{Mean} & \textbf{SD} & \textbf{Min} & \textbf{Max}\\\hline\endhead
\hline \multicolumn{5}{l}{continued on next page}\endfoot
\hline \multicolumn{5}{l}{Source:}\endlastfoot

i100 & avbascadf & 6.748 & 2.209 & 0 & 10\\
\quad\\
\textbf{Independent Variables} \\
\cline{2-6}\\

test & 1 if test, 0 if otherwise      &0.532 & 0.499 & 0 & 1\\
\end{longtable}
}

\end{document}
  • A few judiciously placed \clearpage commands might help, since they will clear any extant floats, as well. – Steven B. Segletes Jan 15 '14 at 16:25
  • clearpage works insofar as it puts the table 5 at last, thus the list sorting according to page numbers works. Its a fix but i'd rather rely on the automatism offered by tex to set tables and number them accordingly. – user1502044 Jan 15 '14 at 16:33
  • @outer_soup \clearpage is as automatic as it gets. (At least if you don't provide a MWE.) – Svend Tveskæg Jan 15 '14 at 16:47
  • @ Scend Tveskæg its not automatic in a sense of i have to manually add it... i'll have a look if i can string together a MWE that actually produces the misbehaviour. – user1502044 Jan 15 '14 at 16:49
  • 2
    You are mixing non-floating tables (longtable) with floating tables and this can lead to wrong numbers. Beside \clearpage you could try \Floatbarrier from the placeins package to prevent that floats go behind a non-float. – Ulrike Fischer Jan 15 '14 at 17:21
  • Ah, I didnt realize that longtable is behaving differently. Still not sure if that is a bug or ... something that has to be kept in mind. – user1502044 Jan 15 '14 at 17:25
  • i added a bug report on this – user1502044 Jan 15 '14 at 19:00
  • I don't see how longtable can possibly be expected to behave in the same way as floating tables since it cannot possibly float. At least, as far as I know, floats cannot break across pages which is pretty much longtable's raison d'être. (In fact, thinking about it, not breaking is probably fairly essential to floats' raison d'être, too.) – cfr Feb 27 '14 at 00:52
  • I also tried \usepackage{fixltx2e} without luck. I read all about not putting labels before captions. This didn't help, but it gave me the idea that since one of my figures didn't have a caption, maybe I could try adding one to see what happened. Indeed, that gave me the proper numbering order, though I do not know why exactly it works. This is likely related to \label needing to be placed after \caption, the rea – bbarker Jan 21 '14 at 20:25
  • Well, to my mind i expect items of the nature "table" to be handled the same way regardless of whether they originate from floats or not. What possible use is automatic numbering (which is done) when the mechanism produces irrational results? Its solved in terms of \clearpage - which i regard as a simple yet messy hack. – user1502044 Feb 28 '14 at 10:03

1 Answers1

1

You are mixing non-floating tables (longtable) with floating tables and this can lead to wrong numbers. Beside \clearpage you could try \Floatbarrier from the placeins package to prevent that floats go behind a non-float.

Theortically it should be also possible to reset the numbering with automatical labels and comparision of the \pageref but someone would have to write the code first.

Ulrike Fischer
  • 327,261