I made a pie chart in my document. When it's not in a figure, everything is fine, the tikzpicture is between the two paragraphs I want. When I make it a figure, it goes to next page:

        \begin{tikzpicture}[nodes = {font=\sffamily}]
        \foreach \percent/\name in {
            81.5/Données reprises,
            18.5/Nouvelles données
            } {
            \ifx\percent\empty\else               % If \percent is empty, do nothing
                \global\advance\cyclecount by 1     % Advance cyclecount
                \global\advance\ind by 1            % Advance list index
                \ifnum3<\cyclecount                 % If cyclecount is larger than list
                \global\cyclecount=0              %   reset cyclecount and
                \global\ind=0                     %   reset list index
                \pgfmathparse{\cyclelist[\the\ind]} % Get color from cycle list
                \edef\color{\pgfmathresult}         %   and store as \color
                % Draw angle and set labels
                \draw[fill={\color!50},draw={\color}] (0,0) -- (\angle:\radius)
                arc (\angle:\angle+\percent*3.6:\radius) -- cycle;
                \node at (\angle+0.5*\percent*3.6:0.7*\radius) {\percent\,\%};
                at (\angle+0.5*\percent*3.6:\radius) {};
                \pgfmathparse{\angle+\percent*3.6}  % Advance angle
                \xdef\angle{\pgfmathresult}         %   and store in \angle
 \caption{Taux de propreté de la donnée}
 \label{Taux de propreté de la donnée}

Is there a way to solve this? Before posting, I checked the other questions, the solution mentionning the "float" is not acceptable for me because I don't want the space between paragraphs to change along the document.

Thanks :)

  • 1
    "Float" is the keyword. It is the float option itself which sends your figure to the next page. – JouleV Feb 12 at 5:33
  • So what do you recommend? I don't want my paragraph to have random space between them. I could make my figure smaller, but it's small enough for me. – djcaesar9114 Feb 12 at 5:43
  • (i) replace center environment with command \centering after \begin{figure}, (ii) replace option [!h] with htb` , (iii) see if you can insert image earlier in text, (iv) provide complete small document which reproduce your problem. – Zarko Feb 12 at 9:58
  • IIRC, [!h} is automatically translated as [htp]. As far as I can tell, the exclamation point does nothing useful, like hitting elevator buttons over and over. – John Kormylo Feb 12 at 16:42
  • Regarding non-floating floats: tex.stackexchange.com/questions/8625/… Regarding space between paragraphs: tex.stackexchange.com/questions/10743/… – Torbjørn T. Feb 12 at 18:03

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.