Possible Duplicate:
Keeping tables/figures close to where they are mentioned
How to influence the position of float environments like figure and table in LaTeX?
I have an appendix in my document consisting of sections named figures, tables before some sections containing text. In the compiled output, I am getting undesired output. The section title does not start where I would like it to be (at the beginning of the first table). It starts after 2 tables.
When I was making an MWE I encountered a couple of strange behaviours. See for yourself. Save a random figure as figure1.png. Though the figure is correct, the output is different depending on whether you type figure1.png or figure.png. The output is still different if you add some sections containing just texts/or remove the textual sections from my example. I would also like my third tabular environment be a table. Please tell me how
\documentclass{article}[12pt] %
\usepackage[capposition=top]{floatrow}
\usepackage{booktabs}% http://ctan.org/pkg/booktabs
\usepackage{array}% http://ctan.org/pkg/array
\usepackage{tabularx}% http://ctan.org/pkg/tabularx
\usepackage{calc}
\usepackage{amsmath}%
\usepackage{amsfonts}%
\usepackage{amssymb}%
\usepackage{graphicx}
\usepackage{breqn}
\usepackage{verbatim}
%\usepackage{biblatex}
\usepackage{apacite}
%-------------------------------------------
\newtheorem{theorem}{Theorem}
\newtheorem{acknowledgement}[theorem]{Acknowledgement}
\newtheorem{algorithm}[theorem]{Algorithm}
\newtheorem{axiom}[theorem]{Axiom}
\newtheorem{case}[theorem]{Case}
\newtheorem{claim}[theorem]{Claim}
\newtheorem{conclusion}[theorem]{Conclusion}
\newtheorem{conjecture}[theorem]{Conjecture}
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{criterion}[theorem]{Criterion}
\newtheorem{definition}[theorem]{Definition}
\newtheorem{example}[theorem]{Example}
\newtheorem{exercise}[theorem]{Exercise}
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{notation}[theorem]{Notation}
\newtheorem{problem}[theorem]{Problem}
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem{remark}[theorem]{Remark}
\newtheorem{solution}[theorem]{Solution}
\newtheorem{summary}[theorem]{Summary}
\newenvironment{proof}[1][Proof]{\textbf{#1.} }{\ \rule{0.5em}{0.5em}}
\linespread{1.3}
\setlength{\pdfpagewidth}{8.5in} \setlength{\pdfpageheight}{11in}
\begin{document}
\appendix
\section{Figures}
\begin{figure}[h]
\caption{Spatial coverage of all events of PRIO'S Urban Social Disturbance in Asia and Africa dataset}
\includegraphics[width=0.80\textwidth]{figure1.png}
\floatfoot{Note: The intensity of the shade indicates the number of events over the period 1990-2010.}
\end{figure}
\section{Tables}
% Table generated by Excel2LaTeX from sheet 'Sheet1'
\begin{table}[htbp]
\caption{Variable sources and features}
\noindent\hspace*{-1cm}\begin{tabularx}{\textwidth+2cm}{
>{\raggedleft\arraybackslash\advance\hsize1em}X
>{\raggedright\arraybackslash\advance\hsize1em }X
>{\raggedright\arraybackslash}X
>{\raggedright\arraybackslash\advance\hsize-1em }X
>{\raggedright\arraybackslash\advance\hsize-1em }X
}
\addlinespace
\toprule
\multicolumn{1}{c}{Variable } & Source & Spatial coverage & Temporal coverage & Frequency \\
\midrule
Urban Social Disturbances & USDAA, PRIO, Oslo & 55 cities (49 countries) & 1960-2010 & Event-based \\
Local food prices & FAO GIEWS database & 43 markets (in common with USDAA) & 1990-Present (unbalanced) & Monthly \\
Total population & WDI 2010 & 190 countries & 1960-2011 & Annual \\
Urban population (as p.c. of total) & WDI 2010 & 190 countries & 1960-2011 & Annual \\
Internet penetration & WDI 2010 & 177 countries & 1960-2011 & Annual \\
Percapita GDP (constant, 2000) & WDI 2010 & 248 countries & 1960-2011 & Annual \\
Index of democracy & QoG database, U of Gothenberg & 202 countries & 1960-2011 & Annual \\
\bottomrule
\end{tabularx}\hspace*{-1cm}%
\label{Sources}%
\end{table}%
\begin{table}[htbp]
\caption{Local food price series used in the analysis}
\noindent\hspace*{-1cm}
{\tiny
\begin{tabularx}{\textwidth+2cm}{
>{\raggedleft\arraybackslash\advance\hsize1em}X
>{\raggedright\arraybackslash\advance\hsize1em }X
>{\raggedright\arraybackslash}X
>{\raggedright\arraybackslash\advance\hsize-1em }X
>{\raggedright\arraybackslash\advance\hsize-1em }X
}
\addlinespace
\toprule
\multicolumn{1}{c}{Country} & Price series selected & Retail (R)/Wholesale(W) & Real(R)/Nominal(N) & Location \\
\midrule
Afghanistan & Bread & R & R & Kabul \\
Bangladesh & Rice & W & N & Dhaka \\
Cambodia & Rice & W & N & Phnom Penh \\
Cameroon & Maize & R & N & Yaonde \\
China & Wheat & R & N & NA \\
(for both Beijing and Lhasa) & & & & \\
DRC & Cassava & R & N & Kinshasa \\
Ethiopia & Sorghum & W & N & Addis Ababa \\
Ghana & Maize & R & R & Accra \\
Guinea & Imported rice & R & N & Conakry \\
India & Rice & R & R & Patna \\
& Wheat & R & R & Delhi \\
& Wheat & R & R & Mumbai \\
Indonesia & Rice & R & R & NA \\
Kazakhstan & Bread & R & R & Almaty \\
Kenya & Maize & W & N & Nairobi \\
Kyrgyzstan & Bread & R & R & Bishkek \\
Laos & Glutinous Rice Grade 1 & R & N & NA \\
Madagascar & Imported Rice & W & R & NA \\
Mali & Imported Rice & W & N & Bamako \\
Mongolia & Wheat & R & R & Ulaan Bator \\
Mozambique & Maize & R & N & Maputo \\
Myanmar & Rice & R & N & NA \\
Nepal & Rice & R & R & Kathmandu \\
Niger & Imported rice & R & R & Niamey \\
Nigeria & Maize & W & R & Kano \\
Pakistan & Wheat flour & R & R & Lahore \\
& Wheat flour & R & R & Karachi \\
Philippines & Regular rice & R & R & Manila \\
Senegal & Imported Rice & R & R & Dakar \\
Somalia & Sorghum & R & N & Mogadishu \\
South Africa & Wheat & W & R & Randfontain \\
Sri Lanka & White Rice & R & R & Colombo \\
Sudan & Sorghum & W & R & Khartoum \\
Tajiskistan & Bread & R & R & Dushanbe \\
Tanzania & Maize & W & R & Dar es Salaam \\
Thailand & 25\% broken rice & W & R & Bangkok \\
Togo & White Maize & R & R & Lome \\
Uganda & Maize & W & R & Kampala \\
Vietnam & Rice & R & R & Hanoi \\
& 25 \% broken rice & R & N & Dong Thap \\
Zambia & White Maize & R & R & NA \\
Zimbabwe & Maize & R & N (USD) & Harare \\
\bottomrule
\end{tabularx}}
\hspace*{-1cm}%
\label{Series}%
\floatfoot{Note: NA stands for National Average.}
\end{table}%
\begin{tabular}{lc} \hline
& (1) \\
VARIABLES & spontevent \\ \hline
& \\
pos\_price\_shock\_ma & 0.287* \\
& (0.154) \\
& \\
Observations & 2,226 \\
Number of city\_group & 37 \\
R-squared & -0.032 \\ \hline
\multicolumn{2}{c}{ Robust standard errors in parentheses} \\
\multicolumn{2}{c}{ *** p$<$0.01, ** p$<$0.05, * p$<$0.1} \\
\end{tabular}
%\section{Figures and Tables}
%\section{Steps in the generation of price series}
\end{document}
h). See How to influence the position of float environments like figure and table in LaTeX? and Keeping tables/figures close to where they are mentioned. Follow the suggestions there to avoid the floating behaviour. Most notably would be the use of thefloatpackage together with theHfloat specifier. – Werner May 22 '12 at 19:14floatpackage (and remove the unnecessary packagesbreqn,verbatim,biblatex,apacite), I get the tables numbered 1 & 2. Something must be amiss with your example, so you are doing something different. – Werner May 22 '12 at 22:50