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.

I am new to TikZ and I can't explain the following behavior when I compile this (with pdflatex or lualatex):

\documentclass[
    fontsize=12pt, 
    DIV=calc, 
    %draft,
    %parskip=half,
    headings=normal, 
    captions=tableheading,
    %final,
    version=last,
    open=right,
    chapterprefix=true,
    %headsepline=true
]{scrreprt}

\usepackage{tikz}
\usepackage{lipsum}

\begin{document}
\lipsum[1]

\begin{tikzpicture}
\tikz \shade[ 
            inner color=black, 
            outer color=yellow
        ]  circle (2.5cm);
\end{tikzpicture}

\lipsum[1]


\end{document}

enter image description here

The generated circle clearly overlaps with the "lipsum" paragraph above it. I have read (TikZ/PGF manual) that I can set a bounding box. Setting one solves the problem but this is not clean : if I add something to the picture, I have to manually resize the bounding box... Furthermore, this is not needed in other TikZ code. Can you explain this behavior? Do you have an idea to solve this problem automatically?

Thanks in advance!

share|improve this question
1  
Remove the second \tikz and you are good to go. It starts a new tikzpicture inside another tikzpicture hence the bounding box calculation gets confused. –  percusse Jun 4 '12 at 17:02

1 Answer 1

up vote 7 down vote accepted

You currently have

\begin{tikzpicture}
\tikz

which is causing the problem. If you just use

\begin{tikzpicture}
\shade[ 
            inner color=black, 
            outer color=yellow
        ]  circle (2.5cm);
\end{tikzpicture}

or else

\tikz \shade[ inner color=black, outer color=yellow]  circle (2.5cm);

then you'll see that it works as expected.

share|improve this answer
5  
You have to finish your post with \fi :) –  percusse Jun 4 '12 at 17:04
    
So stupid of me. I should have read the manual more carefully instead of just jumping from place to place! Thanks percusse and cmhughes for your answers. –  Gael Jun 5 '12 at 7:56

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.