Bug or feature: tikz interprets color specification differently for rectangles












3














When drawing a rectangle, Tikz interprets color in two different ways, depending on in which order it is specified among the options.



In the example below: When color is specified first, as in the first two example, it is used to color the frame of the rectangle---as I'd expect. But in the third rectangle, the red color specification actually fills the rectangle with red. Is this expected?



documentclass{article}

usepackage{tikz}

begin{document}
begin{tikzpicture}
draw[color=red,very thick] (0,0) rectangle (1,1);
draw[color=red,very thick,fill=blue] (2,0) rectangle (3,1);
draw[very thick,fill=blue,color=red] (4,0) rectangle (5,1);
end{tikzpicture}
end{document}


3 squares










share|improve this question



























    3














    When drawing a rectangle, Tikz interprets color in two different ways, depending on in which order it is specified among the options.



    In the example below: When color is specified first, as in the first two example, it is used to color the frame of the rectangle---as I'd expect. But in the third rectangle, the red color specification actually fills the rectangle with red. Is this expected?



    documentclass{article}

    usepackage{tikz}

    begin{document}
    begin{tikzpicture}
    draw[color=red,very thick] (0,0) rectangle (1,1);
    draw[color=red,very thick,fill=blue] (2,0) rectangle (3,1);
    draw[very thick,fill=blue,color=red] (4,0) rectangle (5,1);
    end{tikzpicture}
    end{document}


    3 squares










    share|improve this question

























      3












      3








      3


      1





      When drawing a rectangle, Tikz interprets color in two different ways, depending on in which order it is specified among the options.



      In the example below: When color is specified first, as in the first two example, it is used to color the frame of the rectangle---as I'd expect. But in the third rectangle, the red color specification actually fills the rectangle with red. Is this expected?



      documentclass{article}

      usepackage{tikz}

      begin{document}
      begin{tikzpicture}
      draw[color=red,very thick] (0,0) rectangle (1,1);
      draw[color=red,very thick,fill=blue] (2,0) rectangle (3,1);
      draw[very thick,fill=blue,color=red] (4,0) rectangle (5,1);
      end{tikzpicture}
      end{document}


      3 squares










      share|improve this question













      When drawing a rectangle, Tikz interprets color in two different ways, depending on in which order it is specified among the options.



      In the example below: When color is specified first, as in the first two example, it is used to color the frame of the rectangle---as I'd expect. But in the third rectangle, the red color specification actually fills the rectangle with red. Is this expected?



      documentclass{article}

      usepackage{tikz}

      begin{document}
      begin{tikzpicture}
      draw[color=red,very thick] (0,0) rectangle (1,1);
      draw[color=red,very thick,fill=blue] (2,0) rectangle (3,1);
      draw[very thick,fill=blue,color=red] (4,0) rectangle (5,1);
      end{tikzpicture}
      end{document}


      3 squares







      tikz-pgf color






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 45 mins ago









      Máté Wierdl

      44428




      44428






















          3 Answers
          3






          active

          oldest

          votes


















          3














          You are using the wrong key. color sets fill and draw (if they are set to a color, i.e. it will not add a fill color if you do not specify fill). Use draw to change the frame.



          documentclass{article}

          usepackage{tikz}

          begin{document}
          begin{tikzpicture}
          draw[color=red,very thick] (0,0) rectangle (1,1);
          draw[color=red,very thick,fill=blue] (2,0) rectangle (3,1);
          draw[very thick,fill=blue,draw=red] (4,0) rectangle (5,1);
          end{tikzpicture}
          end{document}





          share|improve this answer





























            3














            Yes because this option rewrites the colors on the draw, fill operations, i quote the 3.0.1a manual on page 165:




            /tikz/color=<color name> (no default) This option sets the color that
            is used for fill, drawing, and text inside the current scope.







            share|improve this answer





























              2














              This is a feature, not a bug.




              • In a path command the color=red is equivalent to text=red.

              • In a draw command the color=red is equivalent to draw=red,text=red.

              • In a fill command the color=red is equivalent to fill=red,text=red.

              • In a filldraw command the color=red is equivalent to fill=red,draw=red,text=red.





              share





















                Your Answer








                StackExchange.ready(function() {
                var channelOptions = {
                tags: "".split(" "),
                id: "85"
                };
                initTagRenderer("".split(" "), "".split(" "), channelOptions);

                StackExchange.using("externalEditor", function() {
                // Have to fire editor after snippets, if snippets enabled
                if (StackExchange.settings.snippets.snippetsEnabled) {
                StackExchange.using("snippets", function() {
                createEditor();
                });
                }
                else {
                createEditor();
                }
                });

                function createEditor() {
                StackExchange.prepareEditor({
                heartbeatType: 'answer',
                autoActivateHeartbeat: false,
                convertImagesToLinks: false,
                noModals: true,
                showLowRepImageUploadWarning: true,
                reputationToPostImages: null,
                bindNavPrevention: true,
                postfix: "",
                imageUploader: {
                brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                allowUrls: true
                },
                onDemand: true,
                discardSelector: ".discard-answer"
                ,immediatelyShowMarkdownHelp:true
                });


                }
                });














                draft saved

                draft discarded


















                StackExchange.ready(
                function () {
                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f468439%2fbug-or-feature-tikz-interprets-color-specification-differently-for-rectangles%23new-answer', 'question_page');
                }
                );

                Post as a guest















                Required, but never shown

























                3 Answers
                3






                active

                oldest

                votes








                3 Answers
                3






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes









                3














                You are using the wrong key. color sets fill and draw (if they are set to a color, i.e. it will not add a fill color if you do not specify fill). Use draw to change the frame.



                documentclass{article}

                usepackage{tikz}

                begin{document}
                begin{tikzpicture}
                draw[color=red,very thick] (0,0) rectangle (1,1);
                draw[color=red,very thick,fill=blue] (2,0) rectangle (3,1);
                draw[very thick,fill=blue,draw=red] (4,0) rectangle (5,1);
                end{tikzpicture}
                end{document}





                share|improve this answer


























                  3














                  You are using the wrong key. color sets fill and draw (if they are set to a color, i.e. it will not add a fill color if you do not specify fill). Use draw to change the frame.



                  documentclass{article}

                  usepackage{tikz}

                  begin{document}
                  begin{tikzpicture}
                  draw[color=red,very thick] (0,0) rectangle (1,1);
                  draw[color=red,very thick,fill=blue] (2,0) rectangle (3,1);
                  draw[very thick,fill=blue,draw=red] (4,0) rectangle (5,1);
                  end{tikzpicture}
                  end{document}





                  share|improve this answer
























                    3












                    3








                    3






                    You are using the wrong key. color sets fill and draw (if they are set to a color, i.e. it will not add a fill color if you do not specify fill). Use draw to change the frame.



                    documentclass{article}

                    usepackage{tikz}

                    begin{document}
                    begin{tikzpicture}
                    draw[color=red,very thick] (0,0) rectangle (1,1);
                    draw[color=red,very thick,fill=blue] (2,0) rectangle (3,1);
                    draw[very thick,fill=blue,draw=red] (4,0) rectangle (5,1);
                    end{tikzpicture}
                    end{document}





                    share|improve this answer












                    You are using the wrong key. color sets fill and draw (if they are set to a color, i.e. it will not add a fill color if you do not specify fill). Use draw to change the frame.



                    documentclass{article}

                    usepackage{tikz}

                    begin{document}
                    begin{tikzpicture}
                    draw[color=red,very thick] (0,0) rectangle (1,1);
                    draw[color=red,very thick,fill=blue] (2,0) rectangle (3,1);
                    draw[very thick,fill=blue,draw=red] (4,0) rectangle (5,1);
                    end{tikzpicture}
                    end{document}






                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered 39 mins ago









                    TeXnician

                    24.5k63086




                    24.5k63086























                        3














                        Yes because this option rewrites the colors on the draw, fill operations, i quote the 3.0.1a manual on page 165:




                        /tikz/color=<color name> (no default) This option sets the color that
                        is used for fill, drawing, and text inside the current scope.







                        share|improve this answer


























                          3














                          Yes because this option rewrites the colors on the draw, fill operations, i quote the 3.0.1a manual on page 165:




                          /tikz/color=<color name> (no default) This option sets the color that
                          is used for fill, drawing, and text inside the current scope.







                          share|improve this answer
























                            3












                            3








                            3






                            Yes because this option rewrites the colors on the draw, fill operations, i quote the 3.0.1a manual on page 165:




                            /tikz/color=<color name> (no default) This option sets the color that
                            is used for fill, drawing, and text inside the current scope.







                            share|improve this answer












                            Yes because this option rewrites the colors on the draw, fill operations, i quote the 3.0.1a manual on page 165:




                            /tikz/color=<color name> (no default) This option sets the color that
                            is used for fill, drawing, and text inside the current scope.








                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered 38 mins ago









                            AndréC

                            7,83011441




                            7,83011441























                                2














                                This is a feature, not a bug.




                                • In a path command the color=red is equivalent to text=red.

                                • In a draw command the color=red is equivalent to draw=red,text=red.

                                • In a fill command the color=red is equivalent to fill=red,text=red.

                                • In a filldraw command the color=red is equivalent to fill=red,draw=red,text=red.





                                share


























                                  2














                                  This is a feature, not a bug.




                                  • In a path command the color=red is equivalent to text=red.

                                  • In a draw command the color=red is equivalent to draw=red,text=red.

                                  • In a fill command the color=red is equivalent to fill=red,text=red.

                                  • In a filldraw command the color=red is equivalent to fill=red,draw=red,text=red.





                                  share
























                                    2












                                    2








                                    2






                                    This is a feature, not a bug.




                                    • In a path command the color=red is equivalent to text=red.

                                    • In a draw command the color=red is equivalent to draw=red,text=red.

                                    • In a fill command the color=red is equivalent to fill=red,text=red.

                                    • In a filldraw command the color=red is equivalent to fill=red,draw=red,text=red.





                                    share












                                    This is a feature, not a bug.




                                    • In a path command the color=red is equivalent to text=red.

                                    • In a draw command the color=red is equivalent to draw=red,text=red.

                                    • In a fill command the color=red is equivalent to fill=red,text=red.

                                    • In a filldraw command the color=red is equivalent to fill=red,draw=red,text=red.






                                    share











                                    share


                                    share










                                    answered 9 mins ago









                                    Kpym

                                    15.7k23984




                                    15.7k23984






























                                        draft saved

                                        draft discarded




















































                                        Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


                                        • Please be sure to answer the question. Provide details and share your research!

                                        But avoid



                                        • Asking for help, clarification, or responding to other answers.

                                        • Making statements based on opinion; back them up with references or personal experience.


                                        To learn more, see our tips on writing great answers.





                                        Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                                        Please pay close attention to the following guidance:


                                        • Please be sure to answer the question. Provide details and share your research!

                                        But avoid



                                        • Asking for help, clarification, or responding to other answers.

                                        • Making statements based on opinion; back them up with references or personal experience.


                                        To learn more, see our tips on writing great answers.




                                        draft saved


                                        draft discarded














                                        StackExchange.ready(
                                        function () {
                                        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f468439%2fbug-or-feature-tikz-interprets-color-specification-differently-for-rectangles%23new-answer', 'question_page');
                                        }
                                        );

                                        Post as a guest















                                        Required, but never shown





















































                                        Required, but never shown














                                        Required, but never shown












                                        Required, but never shown







                                        Required, but never shown

































                                        Required, but never shown














                                        Required, but never shown












                                        Required, but never shown







                                        Required, but never shown







                                        Popular posts from this blog

                                        Eastern Orthodox Church

                                        Zagreb

                                        Understanding the information contained in the Deep Space Network XML data?