Selectively ignoring some pgfkeys based on the existence of a tikz style











up vote
2
down vote

favorite












I want to be able to modify the style of some parts of a complex picture depending on a tag on nodes or pathes (precisely, I have a complex architecture schematic and I want to selectively highlight some datapathes). And I to facilitate maintenance of the picture, I prefer a single source.



One way to do that is:




  1. to declare the tags as empty pgfkeys styles

  2. and to modify their value on demand.




documentclass{article}
usepackage{tikz}
begin{document}
pgfkeys{/tikz/.cd,<slide 1>/.style={}}
pgfkeys{/tikz/.cd,<slide 2>/.style={}}
pgfkeys{/tikz/.cd,<slide 3>/.style={}}
pgfkeys{/tikz/.cd,<slide 4>/.style={}}

newcommand{complexpicture}{

node[draw, <slide 1>] at (0,0) {box 1};
node[draw, <slide 2>] at (2,0) {box 2};
node[draw, <slide 3>] at (4,0) {box 3};
node[draw, <slide 4>] at (6,0) {box 4};
}

General overview (all tags are ignored)
begin{tikzpicture}
complexpicture
end{tikzpicture}

Highlight first item
begin{tikzpicture}[<slide 1>/.style={very thick}]
complexpicture
end{tikzpicture}

Highlight second item
begin{tikzpicture}[<slide 2>/.style={very thick}]
complexpicture
end{tikzpicture}
end{document}


enter image description here



Of course, it works, but the need to previously declare tags is unflexible and inelegant.



So I tried to filter out < tags > with pgfkeys, except when a style exists. I used first char syntax to detect an initial <.



I did not succeed to declare styles starting with a <. So tikzpicture styles are in /tag/name/.style and I filter out < name > pgfkey, unless /tag/name exist.



documentclass{article}

usepackage{tikz}

begin{document}
newcommand{complexpicture}{
node[draw, <slide 1>] at (0,0) {box 1};
node[draw, <slide 2>] at (2,0) {box 2};
node[draw, <slide 3>] at (4,0) {box 3};
node[draw, <slide 4>] at (6,0) {box 4};
}

pgfkeys{
/handlers/first char syntax=true,
/handlers/first char syntax/the character </.initial=mykeymacro
}
defmykeymacro#1{mykeyparser#1someendtext}
defmykeyparser<#1>someendtext{
pgfkeysifdefined{/tag/#1}{pgfkeysvalueof{/tag/#1}}{}
}

General overview (all tags are ignored)\
begin{tikzpicture}
complexpicture
end{tikzpicture}

Highlight first item\
begin{tikzpicture}[/tag/slide 1/.style={very thick}]
complexpicture
end{tikzpicture}

Highlight second item\
begin{tikzpicture}[/tag/slide 2/.style={very thick}]
complexpicture
end{tikzpicture}


end{document}


enter image description here



Actually, it does not work. < tags > are properly filtered out and there is no pgfkeys error, but all theses keys are suppressed and the styles declared in the tikzpicture are never activated. I tried some variations on this scheme, but none did work.



Probably I am missing something...










share|improve this question









New contributor




Alain Merigot is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • Welcome to TeX.SE! Could you please elaborate a tiny bit more on what you are trying to achieve, and, in particular, why? The current output can easily be achieved by putting the nodes in a matrix and saying column 2/.style={thick}, say. (Most likely I just do not understand the purpose of that exercise.)
    – marmot
    3 hours ago












  • Does How do I pass an unknown value to a choice key in pgfkeys? or How to define a style of undefined key choice? (duplicate) answer help?
    – Peter Grill
    2 hours ago












  • This is a MWE. Actually, the picture is ~200 lines and describes the architecture of a processor, with registers, operators and busses. What I want to do is to have several versions. The regular one and others where the path used to implement some instructions is highlighted in red. The picture is fairly complex and can be largely improved,so I want a unique version and a way to easily modify styles of some parts of the picture with a unique code..
    – Alain Merigot
    15 mins ago

















up vote
2
down vote

favorite












I want to be able to modify the style of some parts of a complex picture depending on a tag on nodes or pathes (precisely, I have a complex architecture schematic and I want to selectively highlight some datapathes). And I to facilitate maintenance of the picture, I prefer a single source.



One way to do that is:




  1. to declare the tags as empty pgfkeys styles

  2. and to modify their value on demand.




documentclass{article}
usepackage{tikz}
begin{document}
pgfkeys{/tikz/.cd,<slide 1>/.style={}}
pgfkeys{/tikz/.cd,<slide 2>/.style={}}
pgfkeys{/tikz/.cd,<slide 3>/.style={}}
pgfkeys{/tikz/.cd,<slide 4>/.style={}}

newcommand{complexpicture}{

node[draw, <slide 1>] at (0,0) {box 1};
node[draw, <slide 2>] at (2,0) {box 2};
node[draw, <slide 3>] at (4,0) {box 3};
node[draw, <slide 4>] at (6,0) {box 4};
}

General overview (all tags are ignored)
begin{tikzpicture}
complexpicture
end{tikzpicture}

Highlight first item
begin{tikzpicture}[<slide 1>/.style={very thick}]
complexpicture
end{tikzpicture}

Highlight second item
begin{tikzpicture}[<slide 2>/.style={very thick}]
complexpicture
end{tikzpicture}
end{document}


enter image description here



Of course, it works, but the need to previously declare tags is unflexible and inelegant.



So I tried to filter out < tags > with pgfkeys, except when a style exists. I used first char syntax to detect an initial <.



I did not succeed to declare styles starting with a <. So tikzpicture styles are in /tag/name/.style and I filter out < name > pgfkey, unless /tag/name exist.



documentclass{article}

usepackage{tikz}

begin{document}
newcommand{complexpicture}{
node[draw, <slide 1>] at (0,0) {box 1};
node[draw, <slide 2>] at (2,0) {box 2};
node[draw, <slide 3>] at (4,0) {box 3};
node[draw, <slide 4>] at (6,0) {box 4};
}

pgfkeys{
/handlers/first char syntax=true,
/handlers/first char syntax/the character </.initial=mykeymacro
}
defmykeymacro#1{mykeyparser#1someendtext}
defmykeyparser<#1>someendtext{
pgfkeysifdefined{/tag/#1}{pgfkeysvalueof{/tag/#1}}{}
}

General overview (all tags are ignored)\
begin{tikzpicture}
complexpicture
end{tikzpicture}

Highlight first item\
begin{tikzpicture}[/tag/slide 1/.style={very thick}]
complexpicture
end{tikzpicture}

Highlight second item\
begin{tikzpicture}[/tag/slide 2/.style={very thick}]
complexpicture
end{tikzpicture}


end{document}


enter image description here



Actually, it does not work. < tags > are properly filtered out and there is no pgfkeys error, but all theses keys are suppressed and the styles declared in the tikzpicture are never activated. I tried some variations on this scheme, but none did work.



Probably I am missing something...










share|improve this question









New contributor




Alain Merigot is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • Welcome to TeX.SE! Could you please elaborate a tiny bit more on what you are trying to achieve, and, in particular, why? The current output can easily be achieved by putting the nodes in a matrix and saying column 2/.style={thick}, say. (Most likely I just do not understand the purpose of that exercise.)
    – marmot
    3 hours ago












  • Does How do I pass an unknown value to a choice key in pgfkeys? or How to define a style of undefined key choice? (duplicate) answer help?
    – Peter Grill
    2 hours ago












  • This is a MWE. Actually, the picture is ~200 lines and describes the architecture of a processor, with registers, operators and busses. What I want to do is to have several versions. The regular one and others where the path used to implement some instructions is highlighted in red. The picture is fairly complex and can be largely improved,so I want a unique version and a way to easily modify styles of some parts of the picture with a unique code..
    – Alain Merigot
    15 mins ago















up vote
2
down vote

favorite









up vote
2
down vote

favorite











I want to be able to modify the style of some parts of a complex picture depending on a tag on nodes or pathes (precisely, I have a complex architecture schematic and I want to selectively highlight some datapathes). And I to facilitate maintenance of the picture, I prefer a single source.



One way to do that is:




  1. to declare the tags as empty pgfkeys styles

  2. and to modify their value on demand.




documentclass{article}
usepackage{tikz}
begin{document}
pgfkeys{/tikz/.cd,<slide 1>/.style={}}
pgfkeys{/tikz/.cd,<slide 2>/.style={}}
pgfkeys{/tikz/.cd,<slide 3>/.style={}}
pgfkeys{/tikz/.cd,<slide 4>/.style={}}

newcommand{complexpicture}{

node[draw, <slide 1>] at (0,0) {box 1};
node[draw, <slide 2>] at (2,0) {box 2};
node[draw, <slide 3>] at (4,0) {box 3};
node[draw, <slide 4>] at (6,0) {box 4};
}

General overview (all tags are ignored)
begin{tikzpicture}
complexpicture
end{tikzpicture}

Highlight first item
begin{tikzpicture}[<slide 1>/.style={very thick}]
complexpicture
end{tikzpicture}

Highlight second item
begin{tikzpicture}[<slide 2>/.style={very thick}]
complexpicture
end{tikzpicture}
end{document}


enter image description here



Of course, it works, but the need to previously declare tags is unflexible and inelegant.



So I tried to filter out < tags > with pgfkeys, except when a style exists. I used first char syntax to detect an initial <.



I did not succeed to declare styles starting with a <. So tikzpicture styles are in /tag/name/.style and I filter out < name > pgfkey, unless /tag/name exist.



documentclass{article}

usepackage{tikz}

begin{document}
newcommand{complexpicture}{
node[draw, <slide 1>] at (0,0) {box 1};
node[draw, <slide 2>] at (2,0) {box 2};
node[draw, <slide 3>] at (4,0) {box 3};
node[draw, <slide 4>] at (6,0) {box 4};
}

pgfkeys{
/handlers/first char syntax=true,
/handlers/first char syntax/the character </.initial=mykeymacro
}
defmykeymacro#1{mykeyparser#1someendtext}
defmykeyparser<#1>someendtext{
pgfkeysifdefined{/tag/#1}{pgfkeysvalueof{/tag/#1}}{}
}

General overview (all tags are ignored)\
begin{tikzpicture}
complexpicture
end{tikzpicture}

Highlight first item\
begin{tikzpicture}[/tag/slide 1/.style={very thick}]
complexpicture
end{tikzpicture}

Highlight second item\
begin{tikzpicture}[/tag/slide 2/.style={very thick}]
complexpicture
end{tikzpicture}


end{document}


enter image description here



Actually, it does not work. < tags > are properly filtered out and there is no pgfkeys error, but all theses keys are suppressed and the styles declared in the tikzpicture are never activated. I tried some variations on this scheme, but none did work.



Probably I am missing something...










share|improve this question









New contributor




Alain Merigot is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











I want to be able to modify the style of some parts of a complex picture depending on a tag on nodes or pathes (precisely, I have a complex architecture schematic and I want to selectively highlight some datapathes). And I to facilitate maintenance of the picture, I prefer a single source.



One way to do that is:




  1. to declare the tags as empty pgfkeys styles

  2. and to modify their value on demand.




documentclass{article}
usepackage{tikz}
begin{document}
pgfkeys{/tikz/.cd,<slide 1>/.style={}}
pgfkeys{/tikz/.cd,<slide 2>/.style={}}
pgfkeys{/tikz/.cd,<slide 3>/.style={}}
pgfkeys{/tikz/.cd,<slide 4>/.style={}}

newcommand{complexpicture}{

node[draw, <slide 1>] at (0,0) {box 1};
node[draw, <slide 2>] at (2,0) {box 2};
node[draw, <slide 3>] at (4,0) {box 3};
node[draw, <slide 4>] at (6,0) {box 4};
}

General overview (all tags are ignored)
begin{tikzpicture}
complexpicture
end{tikzpicture}

Highlight first item
begin{tikzpicture}[<slide 1>/.style={very thick}]
complexpicture
end{tikzpicture}

Highlight second item
begin{tikzpicture}[<slide 2>/.style={very thick}]
complexpicture
end{tikzpicture}
end{document}


enter image description here



Of course, it works, but the need to previously declare tags is unflexible and inelegant.



So I tried to filter out < tags > with pgfkeys, except when a style exists. I used first char syntax to detect an initial <.



I did not succeed to declare styles starting with a <. So tikzpicture styles are in /tag/name/.style and I filter out < name > pgfkey, unless /tag/name exist.



documentclass{article}

usepackage{tikz}

begin{document}
newcommand{complexpicture}{
node[draw, <slide 1>] at (0,0) {box 1};
node[draw, <slide 2>] at (2,0) {box 2};
node[draw, <slide 3>] at (4,0) {box 3};
node[draw, <slide 4>] at (6,0) {box 4};
}

pgfkeys{
/handlers/first char syntax=true,
/handlers/first char syntax/the character </.initial=mykeymacro
}
defmykeymacro#1{mykeyparser#1someendtext}
defmykeyparser<#1>someendtext{
pgfkeysifdefined{/tag/#1}{pgfkeysvalueof{/tag/#1}}{}
}

General overview (all tags are ignored)\
begin{tikzpicture}
complexpicture
end{tikzpicture}

Highlight first item\
begin{tikzpicture}[/tag/slide 1/.style={very thick}]
complexpicture
end{tikzpicture}

Highlight second item\
begin{tikzpicture}[/tag/slide 2/.style={very thick}]
complexpicture
end{tikzpicture}


end{document}


enter image description here



Actually, it does not work. < tags > are properly filtered out and there is no pgfkeys error, but all theses keys are suppressed and the styles declared in the tikzpicture are never activated. I tried some variations on this scheme, but none did work.



Probably I am missing something...







tikz-pgf pgfkeys






share|improve this question









New contributor




Alain Merigot is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Alain Merigot is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 1 hour ago









AndréC

6,98211140




6,98211140






New contributor




Alain Merigot is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 3 hours ago









Alain Merigot

111




111




New contributor




Alain Merigot is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Alain Merigot is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Alain Merigot is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • Welcome to TeX.SE! Could you please elaborate a tiny bit more on what you are trying to achieve, and, in particular, why? The current output can easily be achieved by putting the nodes in a matrix and saying column 2/.style={thick}, say. (Most likely I just do not understand the purpose of that exercise.)
    – marmot
    3 hours ago












  • Does How do I pass an unknown value to a choice key in pgfkeys? or How to define a style of undefined key choice? (duplicate) answer help?
    – Peter Grill
    2 hours ago












  • This is a MWE. Actually, the picture is ~200 lines and describes the architecture of a processor, with registers, operators and busses. What I want to do is to have several versions. The regular one and others where the path used to implement some instructions is highlighted in red. The picture is fairly complex and can be largely improved,so I want a unique version and a way to easily modify styles of some parts of the picture with a unique code..
    – Alain Merigot
    15 mins ago




















  • Welcome to TeX.SE! Could you please elaborate a tiny bit more on what you are trying to achieve, and, in particular, why? The current output can easily be achieved by putting the nodes in a matrix and saying column 2/.style={thick}, say. (Most likely I just do not understand the purpose of that exercise.)
    – marmot
    3 hours ago












  • Does How do I pass an unknown value to a choice key in pgfkeys? or How to define a style of undefined key choice? (duplicate) answer help?
    – Peter Grill
    2 hours ago












  • This is a MWE. Actually, the picture is ~200 lines and describes the architecture of a processor, with registers, operators and busses. What I want to do is to have several versions. The regular one and others where the path used to implement some instructions is highlighted in red. The picture is fairly complex and can be largely improved,so I want a unique version and a way to easily modify styles of some parts of the picture with a unique code..
    – Alain Merigot
    15 mins ago


















Welcome to TeX.SE! Could you please elaborate a tiny bit more on what you are trying to achieve, and, in particular, why? The current output can easily be achieved by putting the nodes in a matrix and saying column 2/.style={thick}, say. (Most likely I just do not understand the purpose of that exercise.)
– marmot
3 hours ago






Welcome to TeX.SE! Could you please elaborate a tiny bit more on what you are trying to achieve, and, in particular, why? The current output can easily be achieved by putting the nodes in a matrix and saying column 2/.style={thick}, say. (Most likely I just do not understand the purpose of that exercise.)
– marmot
3 hours ago














Does How do I pass an unknown value to a choice key in pgfkeys? or How to define a style of undefined key choice? (duplicate) answer help?
– Peter Grill
2 hours ago






Does How do I pass an unknown value to a choice key in pgfkeys? or How to define a style of undefined key choice? (duplicate) answer help?
– Peter Grill
2 hours ago














This is a MWE. Actually, the picture is ~200 lines and describes the architecture of a processor, with registers, operators and busses. What I want to do is to have several versions. The regular one and others where the path used to implement some instructions is highlighted in red. The picture is fairly complex and can be largely improved,so I want a unique version and a way to easily modify styles of some parts of the picture with a unique code..
– Alain Merigot
15 mins ago






This is a MWE. Actually, the picture is ~200 lines and describes the architecture of a processor, with registers, operators and busses. What I want to do is to have several versions. The regular one and others where the path used to implement some instructions is highlighted in red. The picture is fairly complex and can be largely improved,so I want a unique version and a way to easily modify styles of some parts of the picture with a unique code..
– Alain Merigot
15 mins ago

















active

oldest

votes











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
});


}
});






Alain Merigot is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f464571%2fselectively-ignoring-some-pgfkeys-based-on-the-existence-of-a-tikz-style%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes








Alain Merigot is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















Alain Merigot is a new contributor. Be nice, and check out our Code of Conduct.













Alain Merigot is a new contributor. Be nice, and check out our Code of Conduct.












Alain Merigot 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.





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%2f464571%2fselectively-ignoring-some-pgfkeys-based-on-the-existence-of-a-tikz-style%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

Futebolista

Lallio

Jornalista