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}
tikz-pgf
add a comment |
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}
tikz-pgf
add a comment |
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}
tikz-pgf
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}
tikz-pgf
tikz-pgf
asked 3 hours ago
lucky1928
1,1341716
1,1341716
add a comment |
add a comment |
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}
add a comment |
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:
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
add a comment |
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}
add a comment |
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}
add a comment |
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}
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}
edited 2 hours ago
answered 2 hours ago
marmot
80.5k491172
80.5k491172
add a comment |
add a comment |
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:
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
add a comment |
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:
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
add a comment |
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:
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
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:
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
edited 1 hour ago
answered 1 hour ago
AndréC
6,62711140
6,62711140
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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