ruler line not in the middle of color bars











up vote
3
down vote

favorite












Below code use positioning packet to put ruler line between two color lines.
But the result not as expected!



documentclass[border=1pt,varwidth=5cm]{standalone}
usepackage{tikz}
usetikzlibrary{positioning}
begin{document}
newcommandcolorrulemix[1]{textcolor{#1!40!gray}{rule{0.5cm}{0.5cm}} }
newcommandcolorrule[1]{textcolor{#1}{rule{0.5cm}{0.5cm}} }
begin{tikzpicture}[node distance=0]
foreach name [count=i] in {{red},{orange},{yellow},{green},{cyan},{blue},{purple}} {
node (Pi) at (i*0.6cm,0) {colorrule{name}};
}
node[below=0.1 of P4] {rule{4.5cm}{1pt}};
foreach name [count=i] in {{red},{orange},{yellow},{green},{cyan},{blue},{purple}} {
node [below=0.2 of Pi] (Qi) {colorrulemix{name}};
}
end{tikzpicture}
end{document}


enter image description here










share|improve this question


























    up vote
    3
    down vote

    favorite












    Below code use positioning packet to put ruler line between two color lines.
    But the result not as expected!



    documentclass[border=1pt,varwidth=5cm]{standalone}
    usepackage{tikz}
    usetikzlibrary{positioning}
    begin{document}
    newcommandcolorrulemix[1]{textcolor{#1!40!gray}{rule{0.5cm}{0.5cm}} }
    newcommandcolorrule[1]{textcolor{#1}{rule{0.5cm}{0.5cm}} }
    begin{tikzpicture}[node distance=0]
    foreach name [count=i] in {{red},{orange},{yellow},{green},{cyan},{blue},{purple}} {
    node (Pi) at (i*0.6cm,0) {colorrule{name}};
    }
    node[below=0.1 of P4] {rule{4.5cm}{1pt}};
    foreach name [count=i] in {{red},{orange},{yellow},{green},{cyan},{blue},{purple}} {
    node [below=0.2 of Pi] (Qi) {colorrulemix{name}};
    }
    end{tikzpicture}
    end{document}


    enter image description here










    share|improve this question
























      up vote
      3
      down vote

      favorite









      up vote
      3
      down vote

      favorite











      Below code use positioning packet to put ruler line between two color lines.
      But the result not as expected!



      documentclass[border=1pt,varwidth=5cm]{standalone}
      usepackage{tikz}
      usetikzlibrary{positioning}
      begin{document}
      newcommandcolorrulemix[1]{textcolor{#1!40!gray}{rule{0.5cm}{0.5cm}} }
      newcommandcolorrule[1]{textcolor{#1}{rule{0.5cm}{0.5cm}} }
      begin{tikzpicture}[node distance=0]
      foreach name [count=i] in {{red},{orange},{yellow},{green},{cyan},{blue},{purple}} {
      node (Pi) at (i*0.6cm,0) {colorrule{name}};
      }
      node[below=0.1 of P4] {rule{4.5cm}{1pt}};
      foreach name [count=i] in {{red},{orange},{yellow},{green},{cyan},{blue},{purple}} {
      node [below=0.2 of Pi] (Qi) {colorrulemix{name}};
      }
      end{tikzpicture}
      end{document}


      enter image description here










      share|improve this question













      Below code use positioning packet to put ruler line between two color lines.
      But the result not as expected!



      documentclass[border=1pt,varwidth=5cm]{standalone}
      usepackage{tikz}
      usetikzlibrary{positioning}
      begin{document}
      newcommandcolorrulemix[1]{textcolor{#1!40!gray}{rule{0.5cm}{0.5cm}} }
      newcommandcolorrule[1]{textcolor{#1}{rule{0.5cm}{0.5cm}} }
      begin{tikzpicture}[node distance=0]
      foreach name [count=i] in {{red},{orange},{yellow},{green},{cyan},{blue},{purple}} {
      node (Pi) at (i*0.6cm,0) {colorrule{name}};
      }
      node[below=0.1 of P4] {rule{4.5cm}{1pt}};
      foreach name [count=i] in {{red},{orange},{yellow},{green},{cyan},{blue},{purple}} {
      node [below=0.2 of Pi] (Qi) {colorrulemix{name}};
      }
      end{tikzpicture}
      end{document}


      enter image description here







      tikz-pgf






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 3 hours ago









      lucky1928

      1,1341716




      1,1341716






















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          2
          down vote













          The main reason why your approach does not quite work is that the nodes have some standard dimensions, most notably inner sep, which distorts the (vertical) position of your bar node. If you remove the inner sep, the bar will sit right below the baseline that is in the middle. You could then shift it down by half its thickness. It is, however, easy enough to draw a perfectly (I hope;-) centered bar with TikZ methods.



          documentclass[border=1pt,varwidth=5cm]{standalone}
          usepackage{tikz}
          usetikzlibrary{positioning}
          begin{document}
          newcommandcolorrulemix[1]{textcolor{#1!40!gray}{rule{0.5cm}{0.5cm}} }
          newcommandcolorrule[1]{textcolor{#1}{rule{0.5cm}{0.5cm}} }

          Your picture:\
          begin{tikzpicture}[node distance=0]
          foreach name [count=i] in {{red},{orange},{yellow},{green},{cyan},{blue},{purple}} {
          node (Pi) at (i*0.6cm,0) {colorrule{name}};
          }
          node[below=0.1 of P4] {rule{4.5cm}{1pt}};
          foreach name [count=i] in {{red},{orange},{yellow},{green},{cyan},{blue},{purple}} {
          node [below=0.2 of Pi] (Qi) {colorrulemix{name}};
          }
          end{tikzpicture}

          Your picture with texttt{inner sep=0pt}:\
          begin{tikzpicture}[node distance=0]
          foreach name [count=i] in {{red},{orange},{yellow},{green},{cyan},{blue},{purple}} {
          node (Pi) at (i*0.6cm,0) {colorrule{name}};
          }
          node[below=0.1 of P4,inner sep=0pt] {rule{4.5cm}{1pt}};
          foreach name [count=i] in {{red},{orange},{yellow},{green},{cyan},{blue},{purple}} {
          node [below=0.2 of Pi] (Qi) {colorrulemix{name}};
          }
          end{tikzpicture}

          Your picture with texttt{inner sep=0pt} and a cross--check:\
          begin{tikzpicture}[node distance=0]
          foreach name [count=i] in {{red},{orange},{yellow},{green},{cyan},{blue},{purple}} {
          node (Pi) at (i*0.6cm,0) {colorrule{name}};
          }
          node[below=0.1 of P4,inner sep=0pt] {rule{4.5cm}{1pt}};
          foreach name [count=i] in {{red},{orange},{yellow},{green},{cyan},{blue},{purple}} {
          node [below=0.2 of Pi] (Qi) {colorrulemix{name}};
          }
          path (Q1) -- (P1) coordinate[midway] (aux) ;
          draw[red](aux) -- ++ (4,0);
          end{tikzpicture}

          An alternative with really centered line:\
          begin{tikzpicture}[node distance=0]
          foreach name [count=i] in {{red},{orange},{yellow},{green},{cyan},{blue},{purple}} {
          node (Pi) at (i*0.6cm,0) {colorrule{name}};
          }
          foreach name [count=i] in {{red},{orange},{yellow},{green},{cyan},{blue},{purple}} {
          node [below=0.2 of Pi] (Qi) {colorrulemix{name}};
          }
          path (Q4) -- (P4) coordinate[midway] (aux) ;
          draw[line width=1pt]([xshift=-2.25cm]aux) -- ++ (4.5,0);
          end{tikzpicture}
          end{document}


          enter image description here






          share|improve this answer






























            up vote
            0
            down vote













            First of all, it is useless to specify the node distance= 0 if you specify the < shift part > of the keys below of= as I explained here : TikZ: How does global/local [node distance] work?



            Then, do not confuse the points of the path and the nodes. Nodes are not part of the path itself and have additional parameters such as the distance between the text and the border (inner sep) and the distance between the border and the outside (outer sep): read pages 218 and 219 of the manual 3.0.1a.



            Thus, it is sufficient to specify these parameters globally



            begin{tikzpicture}[inner sep=0pt,outer sep=0pt] 


            and do not forget that when you go down from 0.2, you have omitted to count the line thickness which is 1pt : rule{4.5cm}{1pt}



            It is therefore necessary to add this length.



            node[below=0.2cm+1pt of Pi] (Qi) {colorrulemix{name}


            The result and the final code are:



            colors



            documentclass[border=1pt,varwidth=5cm]{standalone}
            usepackage{tikz}
            usetikzlibrary{positioning}
            begin{document}
            newcommandcolorrulemix[1]{textcolor{#1!40!gray}{rule{0.5cm}{0.5cm}} }
            newcommandcolorrule[1]{textcolor{#1}{rule{0.5cm}{0.5cm}} }
            begin{tikzpicture}[inner sep=0pt,outer sep=0pt]
            foreach name [count=i] in {{red},{orange},{yellow},{green},{cyan},{blue},{purple}} {
            node (Pi) at (i*0.6cm,0) {colorrule{name}};
            }
            node[below=0.1 of P4] {rule{4.5cm}{1pt}};
            foreach name [count=i] in {{red},{orange},{yellow},{green},{cyan},{blue},{purple}} {
            node [below=0.2cm+1pt of Pi] (Qi) {colorrulemix{name}};
            }
            end{tikzpicture}
            end{document}


            Translated with www.DeepL.com/Translator






            share|improve this answer























              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',
              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%2f463089%2fruler-line-not-in-the-middle-of-color-bars%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes








              up vote
              2
              down vote













              The main reason why your approach does not quite work is that the nodes have some standard dimensions, most notably inner sep, which distorts the (vertical) position of your bar node. If you remove the inner sep, the bar will sit right below the baseline that is in the middle. You could then shift it down by half its thickness. It is, however, easy enough to draw a perfectly (I hope;-) centered bar with TikZ methods.



              documentclass[border=1pt,varwidth=5cm]{standalone}
              usepackage{tikz}
              usetikzlibrary{positioning}
              begin{document}
              newcommandcolorrulemix[1]{textcolor{#1!40!gray}{rule{0.5cm}{0.5cm}} }
              newcommandcolorrule[1]{textcolor{#1}{rule{0.5cm}{0.5cm}} }

              Your picture:\
              begin{tikzpicture}[node distance=0]
              foreach name [count=i] in {{red},{orange},{yellow},{green},{cyan},{blue},{purple}} {
              node (Pi) at (i*0.6cm,0) {colorrule{name}};
              }
              node[below=0.1 of P4] {rule{4.5cm}{1pt}};
              foreach name [count=i] in {{red},{orange},{yellow},{green},{cyan},{blue},{purple}} {
              node [below=0.2 of Pi] (Qi) {colorrulemix{name}};
              }
              end{tikzpicture}

              Your picture with texttt{inner sep=0pt}:\
              begin{tikzpicture}[node distance=0]
              foreach name [count=i] in {{red},{orange},{yellow},{green},{cyan},{blue},{purple}} {
              node (Pi) at (i*0.6cm,0) {colorrule{name}};
              }
              node[below=0.1 of P4,inner sep=0pt] {rule{4.5cm}{1pt}};
              foreach name [count=i] in {{red},{orange},{yellow},{green},{cyan},{blue},{purple}} {
              node [below=0.2 of Pi] (Qi) {colorrulemix{name}};
              }
              end{tikzpicture}

              Your picture with texttt{inner sep=0pt} and a cross--check:\
              begin{tikzpicture}[node distance=0]
              foreach name [count=i] in {{red},{orange},{yellow},{green},{cyan},{blue},{purple}} {
              node (Pi) at (i*0.6cm,0) {colorrule{name}};
              }
              node[below=0.1 of P4,inner sep=0pt] {rule{4.5cm}{1pt}};
              foreach name [count=i] in {{red},{orange},{yellow},{green},{cyan},{blue},{purple}} {
              node [below=0.2 of Pi] (Qi) {colorrulemix{name}};
              }
              path (Q1) -- (P1) coordinate[midway] (aux) ;
              draw[red](aux) -- ++ (4,0);
              end{tikzpicture}

              An alternative with really centered line:\
              begin{tikzpicture}[node distance=0]
              foreach name [count=i] in {{red},{orange},{yellow},{green},{cyan},{blue},{purple}} {
              node (Pi) at (i*0.6cm,0) {colorrule{name}};
              }
              foreach name [count=i] in {{red},{orange},{yellow},{green},{cyan},{blue},{purple}} {
              node [below=0.2 of Pi] (Qi) {colorrulemix{name}};
              }
              path (Q4) -- (P4) coordinate[midway] (aux) ;
              draw[line width=1pt]([xshift=-2.25cm]aux) -- ++ (4.5,0);
              end{tikzpicture}
              end{document}


              enter image description here






              share|improve this answer



























                up vote
                2
                down vote













                The main reason why your approach does not quite work is that the nodes have some standard dimensions, most notably inner sep, which distorts the (vertical) position of your bar node. If you remove the inner sep, the bar will sit right below the baseline that is in the middle. You could then shift it down by half its thickness. It is, however, easy enough to draw a perfectly (I hope;-) centered bar with TikZ methods.



                documentclass[border=1pt,varwidth=5cm]{standalone}
                usepackage{tikz}
                usetikzlibrary{positioning}
                begin{document}
                newcommandcolorrulemix[1]{textcolor{#1!40!gray}{rule{0.5cm}{0.5cm}} }
                newcommandcolorrule[1]{textcolor{#1}{rule{0.5cm}{0.5cm}} }

                Your picture:\
                begin{tikzpicture}[node distance=0]
                foreach name [count=i] in {{red},{orange},{yellow},{green},{cyan},{blue},{purple}} {
                node (Pi) at (i*0.6cm,0) {colorrule{name}};
                }
                node[below=0.1 of P4] {rule{4.5cm}{1pt}};
                foreach name [count=i] in {{red},{orange},{yellow},{green},{cyan},{blue},{purple}} {
                node [below=0.2 of Pi] (Qi) {colorrulemix{name}};
                }
                end{tikzpicture}

                Your picture with texttt{inner sep=0pt}:\
                begin{tikzpicture}[node distance=0]
                foreach name [count=i] in {{red},{orange},{yellow},{green},{cyan},{blue},{purple}} {
                node (Pi) at (i*0.6cm,0) {colorrule{name}};
                }
                node[below=0.1 of P4,inner sep=0pt] {rule{4.5cm}{1pt}};
                foreach name [count=i] in {{red},{orange},{yellow},{green},{cyan},{blue},{purple}} {
                node [below=0.2 of Pi] (Qi) {colorrulemix{name}};
                }
                end{tikzpicture}

                Your picture with texttt{inner sep=0pt} and a cross--check:\
                begin{tikzpicture}[node distance=0]
                foreach name [count=i] in {{red},{orange},{yellow},{green},{cyan},{blue},{purple}} {
                node (Pi) at (i*0.6cm,0) {colorrule{name}};
                }
                node[below=0.1 of P4,inner sep=0pt] {rule{4.5cm}{1pt}};
                foreach name [count=i] in {{red},{orange},{yellow},{green},{cyan},{blue},{purple}} {
                node [below=0.2 of Pi] (Qi) {colorrulemix{name}};
                }
                path (Q1) -- (P1) coordinate[midway] (aux) ;
                draw[red](aux) -- ++ (4,0);
                end{tikzpicture}

                An alternative with really centered line:\
                begin{tikzpicture}[node distance=0]
                foreach name [count=i] in {{red},{orange},{yellow},{green},{cyan},{blue},{purple}} {
                node (Pi) at (i*0.6cm,0) {colorrule{name}};
                }
                foreach name [count=i] in {{red},{orange},{yellow},{green},{cyan},{blue},{purple}} {
                node [below=0.2 of Pi] (Qi) {colorrulemix{name}};
                }
                path (Q4) -- (P4) coordinate[midway] (aux) ;
                draw[line width=1pt]([xshift=-2.25cm]aux) -- ++ (4.5,0);
                end{tikzpicture}
                end{document}


                enter image description here






                share|improve this answer

























                  up vote
                  2
                  down vote










                  up vote
                  2
                  down vote









                  The main reason why your approach does not quite work is that the nodes have some standard dimensions, most notably inner sep, which distorts the (vertical) position of your bar node. If you remove the inner sep, the bar will sit right below the baseline that is in the middle. You could then shift it down by half its thickness. It is, however, easy enough to draw a perfectly (I hope;-) centered bar with TikZ methods.



                  documentclass[border=1pt,varwidth=5cm]{standalone}
                  usepackage{tikz}
                  usetikzlibrary{positioning}
                  begin{document}
                  newcommandcolorrulemix[1]{textcolor{#1!40!gray}{rule{0.5cm}{0.5cm}} }
                  newcommandcolorrule[1]{textcolor{#1}{rule{0.5cm}{0.5cm}} }

                  Your picture:\
                  begin{tikzpicture}[node distance=0]
                  foreach name [count=i] in {{red},{orange},{yellow},{green},{cyan},{blue},{purple}} {
                  node (Pi) at (i*0.6cm,0) {colorrule{name}};
                  }
                  node[below=0.1 of P4] {rule{4.5cm}{1pt}};
                  foreach name [count=i] in {{red},{orange},{yellow},{green},{cyan},{blue},{purple}} {
                  node [below=0.2 of Pi] (Qi) {colorrulemix{name}};
                  }
                  end{tikzpicture}

                  Your picture with texttt{inner sep=0pt}:\
                  begin{tikzpicture}[node distance=0]
                  foreach name [count=i] in {{red},{orange},{yellow},{green},{cyan},{blue},{purple}} {
                  node (Pi) at (i*0.6cm,0) {colorrule{name}};
                  }
                  node[below=0.1 of P4,inner sep=0pt] {rule{4.5cm}{1pt}};
                  foreach name [count=i] in {{red},{orange},{yellow},{green},{cyan},{blue},{purple}} {
                  node [below=0.2 of Pi] (Qi) {colorrulemix{name}};
                  }
                  end{tikzpicture}

                  Your picture with texttt{inner sep=0pt} and a cross--check:\
                  begin{tikzpicture}[node distance=0]
                  foreach name [count=i] in {{red},{orange},{yellow},{green},{cyan},{blue},{purple}} {
                  node (Pi) at (i*0.6cm,0) {colorrule{name}};
                  }
                  node[below=0.1 of P4,inner sep=0pt] {rule{4.5cm}{1pt}};
                  foreach name [count=i] in {{red},{orange},{yellow},{green},{cyan},{blue},{purple}} {
                  node [below=0.2 of Pi] (Qi) {colorrulemix{name}};
                  }
                  path (Q1) -- (P1) coordinate[midway] (aux) ;
                  draw[red](aux) -- ++ (4,0);
                  end{tikzpicture}

                  An alternative with really centered line:\
                  begin{tikzpicture}[node distance=0]
                  foreach name [count=i] in {{red},{orange},{yellow},{green},{cyan},{blue},{purple}} {
                  node (Pi) at (i*0.6cm,0) {colorrule{name}};
                  }
                  foreach name [count=i] in {{red},{orange},{yellow},{green},{cyan},{blue},{purple}} {
                  node [below=0.2 of Pi] (Qi) {colorrulemix{name}};
                  }
                  path (Q4) -- (P4) coordinate[midway] (aux) ;
                  draw[line width=1pt]([xshift=-2.25cm]aux) -- ++ (4.5,0);
                  end{tikzpicture}
                  end{document}


                  enter image description here






                  share|improve this answer














                  The main reason why your approach does not quite work is that the nodes have some standard dimensions, most notably inner sep, which distorts the (vertical) position of your bar node. If you remove the inner sep, the bar will sit right below the baseline that is in the middle. You could then shift it down by half its thickness. It is, however, easy enough to draw a perfectly (I hope;-) centered bar with TikZ methods.



                  documentclass[border=1pt,varwidth=5cm]{standalone}
                  usepackage{tikz}
                  usetikzlibrary{positioning}
                  begin{document}
                  newcommandcolorrulemix[1]{textcolor{#1!40!gray}{rule{0.5cm}{0.5cm}} }
                  newcommandcolorrule[1]{textcolor{#1}{rule{0.5cm}{0.5cm}} }

                  Your picture:\
                  begin{tikzpicture}[node distance=0]
                  foreach name [count=i] in {{red},{orange},{yellow},{green},{cyan},{blue},{purple}} {
                  node (Pi) at (i*0.6cm,0) {colorrule{name}};
                  }
                  node[below=0.1 of P4] {rule{4.5cm}{1pt}};
                  foreach name [count=i] in {{red},{orange},{yellow},{green},{cyan},{blue},{purple}} {
                  node [below=0.2 of Pi] (Qi) {colorrulemix{name}};
                  }
                  end{tikzpicture}

                  Your picture with texttt{inner sep=0pt}:\
                  begin{tikzpicture}[node distance=0]
                  foreach name [count=i] in {{red},{orange},{yellow},{green},{cyan},{blue},{purple}} {
                  node (Pi) at (i*0.6cm,0) {colorrule{name}};
                  }
                  node[below=0.1 of P4,inner sep=0pt] {rule{4.5cm}{1pt}};
                  foreach name [count=i] in {{red},{orange},{yellow},{green},{cyan},{blue},{purple}} {
                  node [below=0.2 of Pi] (Qi) {colorrulemix{name}};
                  }
                  end{tikzpicture}

                  Your picture with texttt{inner sep=0pt} and a cross--check:\
                  begin{tikzpicture}[node distance=0]
                  foreach name [count=i] in {{red},{orange},{yellow},{green},{cyan},{blue},{purple}} {
                  node (Pi) at (i*0.6cm,0) {colorrule{name}};
                  }
                  node[below=0.1 of P4,inner sep=0pt] {rule{4.5cm}{1pt}};
                  foreach name [count=i] in {{red},{orange},{yellow},{green},{cyan},{blue},{purple}} {
                  node [below=0.2 of Pi] (Qi) {colorrulemix{name}};
                  }
                  path (Q1) -- (P1) coordinate[midway] (aux) ;
                  draw[red](aux) -- ++ (4,0);
                  end{tikzpicture}

                  An alternative with really centered line:\
                  begin{tikzpicture}[node distance=0]
                  foreach name [count=i] in {{red},{orange},{yellow},{green},{cyan},{blue},{purple}} {
                  node (Pi) at (i*0.6cm,0) {colorrule{name}};
                  }
                  foreach name [count=i] in {{red},{orange},{yellow},{green},{cyan},{blue},{purple}} {
                  node [below=0.2 of Pi] (Qi) {colorrulemix{name}};
                  }
                  path (Q4) -- (P4) coordinate[midway] (aux) ;
                  draw[line width=1pt]([xshift=-2.25cm]aux) -- ++ (4.5,0);
                  end{tikzpicture}
                  end{document}


                  enter image description here







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited 2 hours ago

























                  answered 2 hours ago









                  marmot

                  80.5k491172




                  80.5k491172






















                      up vote
                      0
                      down vote













                      First of all, it is useless to specify the node distance= 0 if you specify the < shift part > of the keys below of= as I explained here : TikZ: How does global/local [node distance] work?



                      Then, do not confuse the points of the path and the nodes. Nodes are not part of the path itself and have additional parameters such as the distance between the text and the border (inner sep) and the distance between the border and the outside (outer sep): read pages 218 and 219 of the manual 3.0.1a.



                      Thus, it is sufficient to specify these parameters globally



                      begin{tikzpicture}[inner sep=0pt,outer sep=0pt] 


                      and do not forget that when you go down from 0.2, you have omitted to count the line thickness which is 1pt : rule{4.5cm}{1pt}



                      It is therefore necessary to add this length.



                      node[below=0.2cm+1pt of Pi] (Qi) {colorrulemix{name}


                      The result and the final code are:



                      colors



                      documentclass[border=1pt,varwidth=5cm]{standalone}
                      usepackage{tikz}
                      usetikzlibrary{positioning}
                      begin{document}
                      newcommandcolorrulemix[1]{textcolor{#1!40!gray}{rule{0.5cm}{0.5cm}} }
                      newcommandcolorrule[1]{textcolor{#1}{rule{0.5cm}{0.5cm}} }
                      begin{tikzpicture}[inner sep=0pt,outer sep=0pt]
                      foreach name [count=i] in {{red},{orange},{yellow},{green},{cyan},{blue},{purple}} {
                      node (Pi) at (i*0.6cm,0) {colorrule{name}};
                      }
                      node[below=0.1 of P4] {rule{4.5cm}{1pt}};
                      foreach name [count=i] in {{red},{orange},{yellow},{green},{cyan},{blue},{purple}} {
                      node [below=0.2cm+1pt of Pi] (Qi) {colorrulemix{name}};
                      }
                      end{tikzpicture}
                      end{document}


                      Translated with www.DeepL.com/Translator






                      share|improve this answer



























                        up vote
                        0
                        down vote













                        First of all, it is useless to specify the node distance= 0 if you specify the < shift part > of the keys below of= as I explained here : TikZ: How does global/local [node distance] work?



                        Then, do not confuse the points of the path and the nodes. Nodes are not part of the path itself and have additional parameters such as the distance between the text and the border (inner sep) and the distance between the border and the outside (outer sep): read pages 218 and 219 of the manual 3.0.1a.



                        Thus, it is sufficient to specify these parameters globally



                        begin{tikzpicture}[inner sep=0pt,outer sep=0pt] 


                        and do not forget that when you go down from 0.2, you have omitted to count the line thickness which is 1pt : rule{4.5cm}{1pt}



                        It is therefore necessary to add this length.



                        node[below=0.2cm+1pt of Pi] (Qi) {colorrulemix{name}


                        The result and the final code are:



                        colors



                        documentclass[border=1pt,varwidth=5cm]{standalone}
                        usepackage{tikz}
                        usetikzlibrary{positioning}
                        begin{document}
                        newcommandcolorrulemix[1]{textcolor{#1!40!gray}{rule{0.5cm}{0.5cm}} }
                        newcommandcolorrule[1]{textcolor{#1}{rule{0.5cm}{0.5cm}} }
                        begin{tikzpicture}[inner sep=0pt,outer sep=0pt]
                        foreach name [count=i] in {{red},{orange},{yellow},{green},{cyan},{blue},{purple}} {
                        node (Pi) at (i*0.6cm,0) {colorrule{name}};
                        }
                        node[below=0.1 of P4] {rule{4.5cm}{1pt}};
                        foreach name [count=i] in {{red},{orange},{yellow},{green},{cyan},{blue},{purple}} {
                        node [below=0.2cm+1pt of Pi] (Qi) {colorrulemix{name}};
                        }
                        end{tikzpicture}
                        end{document}


                        Translated with www.DeepL.com/Translator






                        share|improve this answer

























                          up vote
                          0
                          down vote










                          up vote
                          0
                          down vote









                          First of all, it is useless to specify the node distance= 0 if you specify the < shift part > of the keys below of= as I explained here : TikZ: How does global/local [node distance] work?



                          Then, do not confuse the points of the path and the nodes. Nodes are not part of the path itself and have additional parameters such as the distance between the text and the border (inner sep) and the distance between the border and the outside (outer sep): read pages 218 and 219 of the manual 3.0.1a.



                          Thus, it is sufficient to specify these parameters globally



                          begin{tikzpicture}[inner sep=0pt,outer sep=0pt] 


                          and do not forget that when you go down from 0.2, you have omitted to count the line thickness which is 1pt : rule{4.5cm}{1pt}



                          It is therefore necessary to add this length.



                          node[below=0.2cm+1pt of Pi] (Qi) {colorrulemix{name}


                          The result and the final code are:



                          colors



                          documentclass[border=1pt,varwidth=5cm]{standalone}
                          usepackage{tikz}
                          usetikzlibrary{positioning}
                          begin{document}
                          newcommandcolorrulemix[1]{textcolor{#1!40!gray}{rule{0.5cm}{0.5cm}} }
                          newcommandcolorrule[1]{textcolor{#1}{rule{0.5cm}{0.5cm}} }
                          begin{tikzpicture}[inner sep=0pt,outer sep=0pt]
                          foreach name [count=i] in {{red},{orange},{yellow},{green},{cyan},{blue},{purple}} {
                          node (Pi) at (i*0.6cm,0) {colorrule{name}};
                          }
                          node[below=0.1 of P4] {rule{4.5cm}{1pt}};
                          foreach name [count=i] in {{red},{orange},{yellow},{green},{cyan},{blue},{purple}} {
                          node [below=0.2cm+1pt of Pi] (Qi) {colorrulemix{name}};
                          }
                          end{tikzpicture}
                          end{document}


                          Translated with www.DeepL.com/Translator






                          share|improve this answer














                          First of all, it is useless to specify the node distance= 0 if you specify the < shift part > of the keys below of= as I explained here : TikZ: How does global/local [node distance] work?



                          Then, do not confuse the points of the path and the nodes. Nodes are not part of the path itself and have additional parameters such as the distance between the text and the border (inner sep) and the distance between the border and the outside (outer sep): read pages 218 and 219 of the manual 3.0.1a.



                          Thus, it is sufficient to specify these parameters globally



                          begin{tikzpicture}[inner sep=0pt,outer sep=0pt] 


                          and do not forget that when you go down from 0.2, you have omitted to count the line thickness which is 1pt : rule{4.5cm}{1pt}



                          It is therefore necessary to add this length.



                          node[below=0.2cm+1pt of Pi] (Qi) {colorrulemix{name}


                          The result and the final code are:



                          colors



                          documentclass[border=1pt,varwidth=5cm]{standalone}
                          usepackage{tikz}
                          usetikzlibrary{positioning}
                          begin{document}
                          newcommandcolorrulemix[1]{textcolor{#1!40!gray}{rule{0.5cm}{0.5cm}} }
                          newcommandcolorrule[1]{textcolor{#1}{rule{0.5cm}{0.5cm}} }
                          begin{tikzpicture}[inner sep=0pt,outer sep=0pt]
                          foreach name [count=i] in {{red},{orange},{yellow},{green},{cyan},{blue},{purple}} {
                          node (Pi) at (i*0.6cm,0) {colorrule{name}};
                          }
                          node[below=0.1 of P4] {rule{4.5cm}{1pt}};
                          foreach name [count=i] in {{red},{orange},{yellow},{green},{cyan},{blue},{purple}} {
                          node [below=0.2cm+1pt of Pi] (Qi) {colorrulemix{name}};
                          }
                          end{tikzpicture}
                          end{document}


                          Translated with www.DeepL.com/Translator







                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited 1 hour ago

























                          answered 1 hour ago









                          AndréC

                          6,62711140




                          6,62711140






























                              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%2f463089%2fruler-line-not-in-the-middle-of-color-bars%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

                              Costa Masnaga

                              Fotorealismo

                              Sidney Franklin