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.

When there is not enough space for TikZ picture at the end of a text, it will goes to the next page, and leaves an empty space after the text. Is there a standard method for putting TikZ picture in the middle of text, flowing the text to the next page, instead of pushing TikZ picture?

A possible method is using wrapfig page, to put TikZ picture inside wrapfigure. This is a flexible method for floating smaller (e.g. half-sized) TikZ picture within text. I am curious if there is a simpler method for arranging full-width TikZ picture within text to avoid any gap throughout the text.

Here is a very simple example:


   \draw[fill=blue] (0,0) rectangle (11,11);

Since the TikZ picture does not fit in the first page, it will goes to the second page and leave an empty space at the bottom of first page. I want to keep the TikZ picture in the first page, and push the excess text to the second page.

In a long text with several TikZ pictures, I want to avoid any gap within the text.

share|improve this question
As @percusse suggests, please compose a fully compilable MWE that illustrates the problem including the \documentclass and the appropriate packages so that those trying to help don't have to recreate it. This will also serve as a test case and ensure that the solution actually works for you. –  Peter Grill Jun 4 '12 at 0:35
The problem is independent of TikZ. What you get with TikZ is a box. TikZ can place this box relatively to the current line (and baseline) or relatively to the page (with overlay). But when the box is in the flow, it's a TeX's box and you need to use the tools linked to floats, figures etc. This is the problem to place a box or a figure in the flow. With pdftex, there are several limitations and this problem is sometimes not easy. –  Alain Matthes Jun 4 '12 at 8:33
Use a figure environment around your tikzpicture. –  Stephan Lehmke Jun 4 '12 at 8:55
@Ali As you stated, wrapfig is good for narrow pictures, but not for full-width ones. figure (which you can use without a dedicated package) is for full-width pictures. –  Stephan Lehmke Jun 4 '12 at 9:11
But I guess a floating {figure} with an {mdframed} environment won’t work … –  Tobi Jun 4 '12 at 9:36

1 Answer 1

The package mdframed also tcolorbox use internal saveboxes. Inside such TeX-construction you can't use any floating material. So you have to adjust manual or avoid such an environment.

share|improve this answer

Your Answer


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.