# How to control latex appendix environment when placing R code in?

I am having a problem with latex environment. When I place r code using \begin{lstlisting} ... code..\end{lstlisting} other objects like tables are displayed only after the script subsections, despite it maintains the order in the content table page.

Anyone knows how can I control this issue? here is my preamble:

\documentclass[12pt,a4paper,oneside]{article}
\usepackage{setspace}
\usepackage{natbib}
\usepackage{booktabs}
\usepackage{dcolumn}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{listings,relsize}
\lstset{
basicstyle=\small,
keywordstyle=\color{red}\itshape,
stringstyle=\ttfamily,
showstringspaces=false,
numbers=left, numberstyle=\tiny,
columns=fullflexible }

-

## migrated from stackoverflow.comJan 31 '13 at 22:56

This question came from our site for professional and enthusiast programmers.

Welcome to TeX.sx! Your post was migrated here from Stack Overflow. Please register on this site, too, and make sure that both accounts are associated with each other (by using the same OpenID), otherwise you won't be able to comment on or accept answers or edit your question. – Werner Jan 31 '13 at 23:11

It's hard to tell given no example, but placing \clearpage before your listing will stop floating figures and tables going past it.