Pass a label in a loop (TiKz)
I want to reproduce the attached figure but I encounter some troubles for the display of labels.
documentclass[tikz]{standalone}
usepackage{color}
tikzset{
zellige/.pic={
draw[ultra thick] (0,0)--(3,3)--(4,2)--(6,2)--(4,0)
--(5,-2)--(4,-2)--(3,-1)--(2,-2)--(1,-2)--cycle;
}
}
begin{document}
begin{tikzpicture}
draw[cyan] (0,-14) grid (42,3);
foreach i in {0,...,9}
foreach j in {0,...,3}{
pic at (4*i,-4*j){zellige};}
foreach i in {0,...,9}
foreach j in {10,...,19}{
node[draw,circle,inner sep=15pt,] at (4*i +2.5,0.1){LARGE j};
}
end{tikzpicture}
end{document}
tikz-pgf
New contributor
add a comment |
I want to reproduce the attached figure but I encounter some troubles for the display of labels.
documentclass[tikz]{standalone}
usepackage{color}
tikzset{
zellige/.pic={
draw[ultra thick] (0,0)--(3,3)--(4,2)--(6,2)--(4,0)
--(5,-2)--(4,-2)--(3,-1)--(2,-2)--(1,-2)--cycle;
}
}
begin{document}
begin{tikzpicture}
draw[cyan] (0,-14) grid (42,3);
foreach i in {0,...,9}
foreach j in {0,...,3}{
pic at (4*i,-4*j){zellige};}
foreach i in {0,...,9}
foreach j in {10,...,19}{
node[draw,circle,inner sep=15pt,] at (4*i +2.5,0.1){LARGE j};
}
end{tikzpicture}
end{document}
tikz-pgf
New contributor
One common trick in TikZ is to use the.try
handler. Ideally speaking, you addpgfkeys{ /Fabrice/i/j/.try }
in the for loop. And then, before the for loop, addpgfkeys{ /Fabrice/i/j/.code = draw the arrow }
.
– Symbol 1
4 hours ago
Or, you can usecoordinate
in apic
and name every instance ofpic
s. That will give you access to those corner points.
– Symbol 1
4 hours ago
Welcome to TeX.SE!
– Kurt
4 hours ago
add a comment |
I want to reproduce the attached figure but I encounter some troubles for the display of labels.
documentclass[tikz]{standalone}
usepackage{color}
tikzset{
zellige/.pic={
draw[ultra thick] (0,0)--(3,3)--(4,2)--(6,2)--(4,0)
--(5,-2)--(4,-2)--(3,-1)--(2,-2)--(1,-2)--cycle;
}
}
begin{document}
begin{tikzpicture}
draw[cyan] (0,-14) grid (42,3);
foreach i in {0,...,9}
foreach j in {0,...,3}{
pic at (4*i,-4*j){zellige};}
foreach i in {0,...,9}
foreach j in {10,...,19}{
node[draw,circle,inner sep=15pt,] at (4*i +2.5,0.1){LARGE j};
}
end{tikzpicture}
end{document}
tikz-pgf
New contributor
I want to reproduce the attached figure but I encounter some troubles for the display of labels.
documentclass[tikz]{standalone}
usepackage{color}
tikzset{
zellige/.pic={
draw[ultra thick] (0,0)--(3,3)--(4,2)--(6,2)--(4,0)
--(5,-2)--(4,-2)--(3,-1)--(2,-2)--(1,-2)--cycle;
}
}
begin{document}
begin{tikzpicture}
draw[cyan] (0,-14) grid (42,3);
foreach i in {0,...,9}
foreach j in {0,...,3}{
pic at (4*i,-4*j){zellige};}
foreach i in {0,...,9}
foreach j in {10,...,19}{
node[draw,circle,inner sep=15pt,] at (4*i +2.5,0.1){LARGE j};
}
end{tikzpicture}
end{document}
tikz-pgf
tikz-pgf
New contributor
New contributor
New contributor
asked 4 hours ago
FabriceFabrice
1,3851922
1,3851922
New contributor
New contributor
One common trick in TikZ is to use the.try
handler. Ideally speaking, you addpgfkeys{ /Fabrice/i/j/.try }
in the for loop. And then, before the for loop, addpgfkeys{ /Fabrice/i/j/.code = draw the arrow }
.
– Symbol 1
4 hours ago
Or, you can usecoordinate
in apic
and name every instance ofpic
s. That will give you access to those corner points.
– Symbol 1
4 hours ago
Welcome to TeX.SE!
– Kurt
4 hours ago
add a comment |
One common trick in TikZ is to use the.try
handler. Ideally speaking, you addpgfkeys{ /Fabrice/i/j/.try }
in the for loop. And then, before the for loop, addpgfkeys{ /Fabrice/i/j/.code = draw the arrow }
.
– Symbol 1
4 hours ago
Or, you can usecoordinate
in apic
and name every instance ofpic
s. That will give you access to those corner points.
– Symbol 1
4 hours ago
Welcome to TeX.SE!
– Kurt
4 hours ago
One common trick in TikZ is to use the
.try
handler. Ideally speaking, you add pgfkeys{ /Fabrice/i/j/.try }
in the for loop. And then, before the for loop, add pgfkeys{ /Fabrice/i/j/.code = draw the arrow }
.– Symbol 1
4 hours ago
One common trick in TikZ is to use the
.try
handler. Ideally speaking, you add pgfkeys{ /Fabrice/i/j/.try }
in the for loop. And then, before the for loop, add pgfkeys{ /Fabrice/i/j/.code = draw the arrow }
.– Symbol 1
4 hours ago
Or, you can use
coordinate
in a pic
and name every instance of pic
s. That will give you access to those corner points.– Symbol 1
4 hours ago
Or, you can use
coordinate
in a pic
and name every instance of pic
s. That will give you access to those corner points.– Symbol 1
4 hours ago
Welcome to TeX.SE!
– Kurt
4 hours ago
Welcome to TeX.SE!
– Kurt
4 hours ago
add a comment |
2 Answers
2
active
oldest
votes
I would just add the node to the definition of the pic
(since pic
s can take arguments).
documentclass[tikz]{standalone}
tikzset{
zellige/.pic={
draw[ultra thick] (0,0)--(3,3)--(4,2)--(6,2)--(4,0)
--(5,-2)--(4,-2)--(3,-1)--(2,-2)--(1,-2)--cycle;
node[draw,circle,inner sep=15pt,font=LARGE] at (2.75,0.25) {#1};
}
}
begin{document}
begin{tikzpicture}
draw[cyan] (0,-14) grid (42,3);
foreach i in {0,...,9}
{foreach j [evaluate=j as k using {int(10+10*j+i)}] in {0,...,3}{
pic at (4*i,-4*j){zellige=k};}}
end{tikzpicture}
end{document}
add a comment |
It is enough to place the labels in the loop that builds the zelliges.
documentclass[tikz]{standalone}
usepackage{color}
tikzset{
zellige/.pic={
draw[ultra thick] (0,0)--(3,3)--(4,2)--(6,2)--(4,0)
--(5,-2)--(4,-2)--(3,-1)--(2,-2)--(1,-2)--cycle;
}
}
begin{document}
begin{tikzpicture}
draw[cyan] (0,-14) grid (42,3);
foreach i in {0,...,9}{
foreach j [evaluate=j as lab using int((j+1)*10+i)]in {0,...,3}{
pic at (4*i,-4*j){zellige};
node[draw,circle,inner sep=15pt] at (4*i+2.5,-4*j){LARGE lab};}
}
end{tikzpicture}
end{document}
@Marmot and AndréC Thanks !
– Fabrice
3 hours ago
add a comment |
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
});
}
});
Fabrice is a new contributor. Be nice, and check out our Code of Conduct.
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%2f472293%2fpass-a-label-in-a-loop-tikz%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
I would just add the node to the definition of the pic
(since pic
s can take arguments).
documentclass[tikz]{standalone}
tikzset{
zellige/.pic={
draw[ultra thick] (0,0)--(3,3)--(4,2)--(6,2)--(4,0)
--(5,-2)--(4,-2)--(3,-1)--(2,-2)--(1,-2)--cycle;
node[draw,circle,inner sep=15pt,font=LARGE] at (2.75,0.25) {#1};
}
}
begin{document}
begin{tikzpicture}
draw[cyan] (0,-14) grid (42,3);
foreach i in {0,...,9}
{foreach j [evaluate=j as k using {int(10+10*j+i)}] in {0,...,3}{
pic at (4*i,-4*j){zellige=k};}}
end{tikzpicture}
end{document}
add a comment |
I would just add the node to the definition of the pic
(since pic
s can take arguments).
documentclass[tikz]{standalone}
tikzset{
zellige/.pic={
draw[ultra thick] (0,0)--(3,3)--(4,2)--(6,2)--(4,0)
--(5,-2)--(4,-2)--(3,-1)--(2,-2)--(1,-2)--cycle;
node[draw,circle,inner sep=15pt,font=LARGE] at (2.75,0.25) {#1};
}
}
begin{document}
begin{tikzpicture}
draw[cyan] (0,-14) grid (42,3);
foreach i in {0,...,9}
{foreach j [evaluate=j as k using {int(10+10*j+i)}] in {0,...,3}{
pic at (4*i,-4*j){zellige=k};}}
end{tikzpicture}
end{document}
add a comment |
I would just add the node to the definition of the pic
(since pic
s can take arguments).
documentclass[tikz]{standalone}
tikzset{
zellige/.pic={
draw[ultra thick] (0,0)--(3,3)--(4,2)--(6,2)--(4,0)
--(5,-2)--(4,-2)--(3,-1)--(2,-2)--(1,-2)--cycle;
node[draw,circle,inner sep=15pt,font=LARGE] at (2.75,0.25) {#1};
}
}
begin{document}
begin{tikzpicture}
draw[cyan] (0,-14) grid (42,3);
foreach i in {0,...,9}
{foreach j [evaluate=j as k using {int(10+10*j+i)}] in {0,...,3}{
pic at (4*i,-4*j){zellige=k};}}
end{tikzpicture}
end{document}
I would just add the node to the definition of the pic
(since pic
s can take arguments).
documentclass[tikz]{standalone}
tikzset{
zellige/.pic={
draw[ultra thick] (0,0)--(3,3)--(4,2)--(6,2)--(4,0)
--(5,-2)--(4,-2)--(3,-1)--(2,-2)--(1,-2)--cycle;
node[draw,circle,inner sep=15pt,font=LARGE] at (2.75,0.25) {#1};
}
}
begin{document}
begin{tikzpicture}
draw[cyan] (0,-14) grid (42,3);
foreach i in {0,...,9}
{foreach j [evaluate=j as k using {int(10+10*j+i)}] in {0,...,3}{
pic at (4*i,-4*j){zellige=k};}}
end{tikzpicture}
end{document}
answered 3 hours ago
marmotmarmot
95.1k4110210
95.1k4110210
add a comment |
add a comment |
It is enough to place the labels in the loop that builds the zelliges.
documentclass[tikz]{standalone}
usepackage{color}
tikzset{
zellige/.pic={
draw[ultra thick] (0,0)--(3,3)--(4,2)--(6,2)--(4,0)
--(5,-2)--(4,-2)--(3,-1)--(2,-2)--(1,-2)--cycle;
}
}
begin{document}
begin{tikzpicture}
draw[cyan] (0,-14) grid (42,3);
foreach i in {0,...,9}{
foreach j [evaluate=j as lab using int((j+1)*10+i)]in {0,...,3}{
pic at (4*i,-4*j){zellige};
node[draw,circle,inner sep=15pt] at (4*i+2.5,-4*j){LARGE lab};}
}
end{tikzpicture}
end{document}
@Marmot and AndréC Thanks !
– Fabrice
3 hours ago
add a comment |
It is enough to place the labels in the loop that builds the zelliges.
documentclass[tikz]{standalone}
usepackage{color}
tikzset{
zellige/.pic={
draw[ultra thick] (0,0)--(3,3)--(4,2)--(6,2)--(4,0)
--(5,-2)--(4,-2)--(3,-1)--(2,-2)--(1,-2)--cycle;
}
}
begin{document}
begin{tikzpicture}
draw[cyan] (0,-14) grid (42,3);
foreach i in {0,...,9}{
foreach j [evaluate=j as lab using int((j+1)*10+i)]in {0,...,3}{
pic at (4*i,-4*j){zellige};
node[draw,circle,inner sep=15pt] at (4*i+2.5,-4*j){LARGE lab};}
}
end{tikzpicture}
end{document}
@Marmot and AndréC Thanks !
– Fabrice
3 hours ago
add a comment |
It is enough to place the labels in the loop that builds the zelliges.
documentclass[tikz]{standalone}
usepackage{color}
tikzset{
zellige/.pic={
draw[ultra thick] (0,0)--(3,3)--(4,2)--(6,2)--(4,0)
--(5,-2)--(4,-2)--(3,-1)--(2,-2)--(1,-2)--cycle;
}
}
begin{document}
begin{tikzpicture}
draw[cyan] (0,-14) grid (42,3);
foreach i in {0,...,9}{
foreach j [evaluate=j as lab using int((j+1)*10+i)]in {0,...,3}{
pic at (4*i,-4*j){zellige};
node[draw,circle,inner sep=15pt] at (4*i+2.5,-4*j){LARGE lab};}
}
end{tikzpicture}
end{document}
It is enough to place the labels in the loop that builds the zelliges.
documentclass[tikz]{standalone}
usepackage{color}
tikzset{
zellige/.pic={
draw[ultra thick] (0,0)--(3,3)--(4,2)--(6,2)--(4,0)
--(5,-2)--(4,-2)--(3,-1)--(2,-2)--(1,-2)--cycle;
}
}
begin{document}
begin{tikzpicture}
draw[cyan] (0,-14) grid (42,3);
foreach i in {0,...,9}{
foreach j [evaluate=j as lab using int((j+1)*10+i)]in {0,...,3}{
pic at (4*i,-4*j){zellige};
node[draw,circle,inner sep=15pt] at (4*i+2.5,-4*j){LARGE lab};}
}
end{tikzpicture}
end{document}
answered 3 hours ago
AndréCAndréC
8,78411447
8,78411447
@Marmot and AndréC Thanks !
– Fabrice
3 hours ago
add a comment |
@Marmot and AndréC Thanks !
– Fabrice
3 hours ago
@Marmot and AndréC Thanks !
– Fabrice
3 hours ago
@Marmot and AndréC Thanks !
– Fabrice
3 hours ago
add a comment |
Fabrice is a new contributor. Be nice, and check out our Code of Conduct.
Fabrice is a new contributor. Be nice, and check out our Code of Conduct.
Fabrice is a new contributor. Be nice, and check out our Code of Conduct.
Fabrice is a new contributor. Be nice, and check out our Code of Conduct.
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.
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%2f472293%2fpass-a-label-in-a-loop-tikz%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
One common trick in TikZ is to use the
.try
handler. Ideally speaking, you addpgfkeys{ /Fabrice/i/j/.try }
in the for loop. And then, before the for loop, addpgfkeys{ /Fabrice/i/j/.code = draw the arrow }
.– Symbol 1
4 hours ago
Or, you can use
coordinate
in apic
and name every instance ofpic
s. That will give you access to those corner points.– Symbol 1
4 hours ago
Welcome to TeX.SE!
– Kurt
4 hours ago