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.

is it possible to prevent a float from being placed within a paragraph? I know there has been another post (How to protect text from being split by a float?) with a similar question, but I would like to allow the float to be placed after the paragraph as well.

This minimal working example (shortened) illustrates what I mean:

\documentclass[a4paper,10pt]{scrreprt}
\usepackage[utf8]{inputenc}

\begin{document}

\begin{figure}[htbp]
   \def\a{ I am a figure}
   \a\\\a\\\a\\\a\\\a\\\a\\\a\\\a\\\a\\\a\\\a
\end{figure}

\begin{figure}[htbp]
    \def\b{I am another figure}
    \b\\\b\\\b\\\b\\\b\\\b\\\b\\\b\\\b\\\b\\\b
\end{figure}

\begin{figure}[htbp]
    \def\c{I am yet another figure}
    \c\\\c\\\c\\\c\\\c\\\c\\\c\\\c\\\c\\\c\\\c
\end{figure}

\def\d{I am text}
\d\\\d\\\d\\\d\\\d\\\d\\\d\\\d\\\d\\\d\\
\d\\\d\\\d\\\d\\\d\\\d\\\d\\\d\\\d\\\d\\
\d\\\d\\\d\\\d\\\d\\\d\\\d\\\d\\\d\\\d\\
\d\\\d\\\d\\\d\\\d\\\d\\\d\\\d\\\d\\\d\\
\d\\\d\\\d\\\d\\\d\\\d\\\d\\\d\\\d\\\d\\
\d\\\d\\\d\\\d\\\d\\\d\\\d\\\d\\\d\\\d\\
\d\\\d\\\d\\\d\\\d\\\d\\\d\\\d\\\d\\\d\\
\d\\\d\\\d\\\d\\\d\\\d\\\d\\\d\\\d\\\d\\
\d\\\d\\\d\\\d\\\d\\\d\\\d\\\d\\\d\\\d\\
\d\\\d\\\d\\\d\\\d\\\d\\\d\\\d\\\d\\\d
\end{document}

Using the solution from the post I linked above, the three figures would be forced to be placed before the text, but I would like to allow the following solution as well:

FIGURE1
FIGURE2
TEXT
FIGURE3

I thought maybe it is possible to place the text in some kind of a boxed environment (page breaks inside the paragraph must be possible).

share|improve this question
    
It's true, you don't have to use the figure environment to place a float/figure. Using the caption package, you can place the final figure in a minipage after the text and use \captionof{figure}{<caption>}. –  Werner Mar 23 '13 at 16:49
    
I updated the example to show the problem without needing to be edited. –  David Carlisle Mar 23 '13 at 17:23

1 Answer 1

Changing float placement parameters mid document is a bit fragile, but this works here

\documentclass[a4paper,10pt]{scrreprt}
\usepackage[utf8]{inputenc}
\usepackage{afterpage}
\begin{document}

\begin{figure}[htbp]
   \def\a{ I am a figure}
   \a\\\a\\\a\\\a\\\a\\\a\\\a\\\a\\\a\\\a\\\a
\end{figure}

\begin{figure}[htbp]
    \def\b{I am another figure}
    \b\\\b\\\b\\\b\\\b\\\b\\\b\\\b\\\b\\\b\\\b
\end{figure}

\begin{figure}[htbp]
    \def\c{I am yet another figure}
    \c\\\c\\\c\\\c\\\c\\\c\\\c\\\c\\\c\\\c\\\c
\end{figure}


{\setcounter{totalnumber}{0}
\def\d{I am text}
\d\\\d\\\d\\\d\\\d\\\d\\\d\\\d\\\d\\\d\\
\d\\\d\\\d\\\d\\\d\\\d\\\d\\\d\\\d\\\d\\
\d\\\d\\\d\\\d\\\d\\\d\\\d\\\d\\\d\\\d\\
\d\\\d\\\d\\\d\\\d\\\d\\\d\\\d\\\d\\\d\\
\d\\\d\\\d\\\d\\\d\\\d\\\d\\\d\\\d\\\d\\
\d\\\d\\\d\\\d\\\d\\\d\\\d\\\d\\\d\\\d\\
\d\\\d\\\d\\\d\\\d\\\d\\\d\\\d\\\d\\\d\\
\d\\\d\\\d\\\d\\\d\\\d\\\d\\\d\\\d\\\d\\
\d\\\d\\\d\\\d\\\d\\\d\\\d\\\d\\\d\\\d\\
\d\\\d\\\d\\\d\\\d\\\d\\\d\\\d\\\d\\\d}\afterpage{\setcounter{totalnumber}{3}}

\end{document}
share|improve this answer
    
Hi, I first thought this would do exactly what I wanted, but unfortunately this does not allow the third figure to be placed directly after the text. Instead, it needs to be placed on a new page. This is somewhat important for me as I actually have several of these blocks along with some figures. I want to have the figures between the blocks, but don't want them to split the blocks. –  Baertierchen Mar 24 '13 at 21:58
    
How do you want it to be placed after the text? it can not be h as it has already floated, if it were t then it would move back up the page into the marked region. You could allow b on the last page, but that would be a bit tricky in case adding the b float pushed some of the marked text over to the next page which is not allowed. –  David Carlisle Mar 24 '13 at 22:08
    
I would like to have it like this: (FLOAT) TEXT (FLOAT) TEST (FLOAT) ... where TEXT are the paragraphs, and (FLOAT) is a place where a float is allowed. Page breaks are allowed within the text paragraphs. –  Baertierchen Mar 25 '13 at 23:22
    
But latex floats go at top or bottoms of pages they don't go mid-page except for the special case of h where the float can go at the point it is defined. Why do you need floats at all why not just use captioned tables (or images) and have them and the text appear in the order they appear in the source. It appears that you don't want any of the properties of a floating environment. –  David Carlisle Mar 25 '13 at 23:29

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.