Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

And again I have another problem I just can't figure out. I defined a listing with some XML code:

\begin{lstlisting}[captionpos=b, caption=XML detection strategy for Refused Parent Bequest, label=lst:refused_parent_bequest]
 <strategy name="Refused Parent Bequest" ...>
    <gate type="AND">
      <gate type="OR">
        <gate type="AND">
          <rule>
            <metric>NProtM</metric>
            <comparison>greater than</comparison>
            <value>10</value>
          </rule>
          <rule>
            <metric>BUR</metric>
            <comparison>smaller than</comparison>
            <value>0.33</value>
          </rule>
        </gate>
        <rule>
          <metric>BOvR</metric>
          <comparison>smaller than</comparison>
          <value>0.33</value>
        </rule>
      </gate>
      <gate type="AND">
        <gate type="OR">
          <rule>
            <metric>AMW</metric>
            <comparison>greater than</comparison>
            <value>-1</value>
          </rule>
          <rule>
            <metric>WMC</metric>
            <comparison>greater than</comparison>
            <value>-1</value>
          </rule>
        </gate>
        <rule>
          <metric>NOM</metric>
          <comparison>greater than</comparison>
          <value>-1</value>
        </rule>
      </gate>
    </gate>
  </strategy>
\end{lstlisting}

Very near to this I also defined a table. Now the problem is the listing starts on the first page, the there is a page break, then there is the table and then the listing continues. How can I force the layout to not interrupt my listing?

share|improve this question
    
add comment

2 Answers

up vote 4 down vote accepted

You can adjust the placing of floats the following ways:

For once you could add \FloatBarrier from the placeins package before the listing to flush all previous floats. This wont help if the table is defined just after it.

The \suppressfloats macro allows you to suppress floats on the current page. You could add it before the listing inside an \afterpage{...} (afterpage package) so that it counts for the second page of the listing.

There is also the flafter package which makes floats only appear after their definition. This should handle a table defined shortly after the listing.

share|improve this answer
add comment

Another (and less hacky) possibility is, to add the float Parameter to your listing. It will then float like the tables do, but floating environments don't interrupt each other:

\begin{lstlisting}[float]
Some Code
\end{lstlisting}

I consider this to be less hacky, because normally having floating content interrupt non floating content ist what you expect and trying to prevent it is contrary to the concepts of TeX.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.