How to use ExplSyntaxOn and ExplSyntaxOff inside tikzset?What do ExplSyntaxOn and ExplSyntaxOff do?How to define the default vertical distance between nodes?Numerical conditional within tikz keys?TikZ: Drawing an arc from an intersection to an intersectionHow to prevent rounded and duplicated tick labels in pgfplots with fixed precision?Drawing rectilinear curves in Tikz, aka an Etch-a-Sketch drawingLine up nested tikz enviroments or how to get rid of themProblems with nested TikZpicturesCan ExplSyntaxOn and ExplSyntaxOff be nested?csvsimple's csvreader error inside ExplSyntaxOn ExplSyntaxOff
Does a windmilling propeller create more drag than a stopped propeller in an engine out scenario
Cycling to work - 30mile return
Can an airline pilot be prosecuted for killing an unruly passenger who could not be physically restrained?
Can more than one instance of Bend Luck be applied to the same roll by multiple Wild Magic sorcerers?
Why is the S-duct intake on the Tu-154 uniquely oblong?
Why use a retrograde orbit?
How do you cope with rejection?
How can sister protect herself from impulse purchases with a credit card?
Have the writers and actors of GOT responded to its poor reception?
How does this piece of code determine array size without using sizeof( )?
Is it standard to have the first week's pay indefinitely withheld?
What would be the game balance implications for using the Gygax method for applying falling damage?
FIFO data structure in pure C
Divisor Rich and Poor Numbers
Is it possible to determine from only a photo of a cityscape whether it was taken close with wide angle or from a distance with zoom?
Are there any crystals that are theoretically possible, but haven't yet been made?
Does the usage of mathematical symbols work differently in books than in theses?
Why didn't Daenerys' advisers suggest assassinating Cersei?
Prints each letter of a string in different colors
Why does the U.S military use mercenaries?
Failing students when it might cause them economic ruin
Managing heat dissipation in a magic wand
Gambler's Fallacy Dice
Is my homebrew Awakened Bear race balanced?
How to use ExplSyntaxOn and ExplSyntaxOff inside tikzset?
What do ExplSyntaxOn and ExplSyntaxOff do?How to define the default vertical distance between nodes?Numerical conditional within tikz keys?TikZ: Drawing an arc from an intersection to an intersectionHow to prevent rounded and duplicated tick labels in pgfplots with fixed precision?Drawing rectilinear curves in Tikz, aka an Etch-a-Sketch drawingLine up nested tikz enviroments or how to get rid of themProblems with nested TikZpicturesCan ExplSyntaxOn and ExplSyntaxOff be nested?csvsimple's csvreader error inside ExplSyntaxOn ExplSyntaxOff
If you place ExplSyntax
on/off inside tikzset
, code (that is expected to work) within ExplSyntax
would generate errors. But if you bring ExplSyntax
outside of tikzset
(enclosing the tikzset
), it makes tikzset
behave unexpectedly. How can I use ExplSyntax
inside tikzset
? Or do I need to (disappointingly, yet again) search for work arounds?
Block within ExplSyntax
generates an error inside tikzset
:
documentclass[varwidth]standalone
usepackageexpl3
usepackagetikz
ExplSyntaxOn
int_new:NmyCounter
int_set:NnmyCounter0
ExplSyntaxOff
tikzset
every node/.style=
/utils/exec=
ExplSyntaxOn
% following line generate an error
% int_incr:NmyCounter
ExplSyntaxOff
begindocument
begintikzpicture
path nodesome text;
endtikzpicture
enddocument
Although block within ExplSyntax does not generate an error, it does not increment myCounter
, causes labels and positioning commands (who knows what else) within tikzset
to generate errors, and prevents a standard counter (myStandardCounter
) from being incremented:
documentclass[varwidth]standalone
usepackageexpl3
usepackagetikz
newcountermyStandardCounter
% let's bring ExplSyntax outside of tikzset and try again
ExplSyntaxOn
int_new:NmyCounter
int_set:NnmyCounter0
tikzset
every node/.style=
/utils/exec=
% neither of the counters below are incremented
int_incr:NmyCounter
stepcountermyStandardCounter
ExplSyntaxOff
begindocument
begintikzpicture
path nodesome text;
endtikzpicture
% both counters are at their initial values (zero)
ExplSyntaxOn
expl3~counter:~int_use:NmyCounter
ExplSyntaxOff
standard counter: thevaluemyStandardCounter
enddocument
tikz-pgf tikz-styles expl3 latex3
add a comment |
If you place ExplSyntax
on/off inside tikzset
, code (that is expected to work) within ExplSyntax
would generate errors. But if you bring ExplSyntax
outside of tikzset
(enclosing the tikzset
), it makes tikzset
behave unexpectedly. How can I use ExplSyntax
inside tikzset
? Or do I need to (disappointingly, yet again) search for work arounds?
Block within ExplSyntax
generates an error inside tikzset
:
documentclass[varwidth]standalone
usepackageexpl3
usepackagetikz
ExplSyntaxOn
int_new:NmyCounter
int_set:NnmyCounter0
ExplSyntaxOff
tikzset
every node/.style=
/utils/exec=
ExplSyntaxOn
% following line generate an error
% int_incr:NmyCounter
ExplSyntaxOff
begindocument
begintikzpicture
path nodesome text;
endtikzpicture
enddocument
Although block within ExplSyntax does not generate an error, it does not increment myCounter
, causes labels and positioning commands (who knows what else) within tikzset
to generate errors, and prevents a standard counter (myStandardCounter
) from being incremented:
documentclass[varwidth]standalone
usepackageexpl3
usepackagetikz
newcountermyStandardCounter
% let's bring ExplSyntax outside of tikzset and try again
ExplSyntaxOn
int_new:NmyCounter
int_set:NnmyCounter0
tikzset
every node/.style=
/utils/exec=
% neither of the counters below are incremented
int_incr:NmyCounter
stepcountermyStandardCounter
ExplSyntaxOff
begindocument
begintikzpicture
path nodesome text;
endtikzpicture
% both counters are at their initial values (zero)
ExplSyntaxOn
expl3~counter:~int_use:NmyCounter
ExplSyntaxOff
standard counter: thevaluemyStandardCounter
enddocument
tikz-pgf tikz-styles expl3 latex3
It won't work inside. You have to set the catcodes (i.e.,ExplSyntaxOn
) before the command (tikzset
) reads its argument.
– Phelype Oleinik
6 hours ago
add a comment |
If you place ExplSyntax
on/off inside tikzset
, code (that is expected to work) within ExplSyntax
would generate errors. But if you bring ExplSyntax
outside of tikzset
(enclosing the tikzset
), it makes tikzset
behave unexpectedly. How can I use ExplSyntax
inside tikzset
? Or do I need to (disappointingly, yet again) search for work arounds?
Block within ExplSyntax
generates an error inside tikzset
:
documentclass[varwidth]standalone
usepackageexpl3
usepackagetikz
ExplSyntaxOn
int_new:NmyCounter
int_set:NnmyCounter0
ExplSyntaxOff
tikzset
every node/.style=
/utils/exec=
ExplSyntaxOn
% following line generate an error
% int_incr:NmyCounter
ExplSyntaxOff
begindocument
begintikzpicture
path nodesome text;
endtikzpicture
enddocument
Although block within ExplSyntax does not generate an error, it does not increment myCounter
, causes labels and positioning commands (who knows what else) within tikzset
to generate errors, and prevents a standard counter (myStandardCounter
) from being incremented:
documentclass[varwidth]standalone
usepackageexpl3
usepackagetikz
newcountermyStandardCounter
% let's bring ExplSyntax outside of tikzset and try again
ExplSyntaxOn
int_new:NmyCounter
int_set:NnmyCounter0
tikzset
every node/.style=
/utils/exec=
% neither of the counters below are incremented
int_incr:NmyCounter
stepcountermyStandardCounter
ExplSyntaxOff
begindocument
begintikzpicture
path nodesome text;
endtikzpicture
% both counters are at their initial values (zero)
ExplSyntaxOn
expl3~counter:~int_use:NmyCounter
ExplSyntaxOff
standard counter: thevaluemyStandardCounter
enddocument
tikz-pgf tikz-styles expl3 latex3
If you place ExplSyntax
on/off inside tikzset
, code (that is expected to work) within ExplSyntax
would generate errors. But if you bring ExplSyntax
outside of tikzset
(enclosing the tikzset
), it makes tikzset
behave unexpectedly. How can I use ExplSyntax
inside tikzset
? Or do I need to (disappointingly, yet again) search for work arounds?
Block within ExplSyntax
generates an error inside tikzset
:
documentclass[varwidth]standalone
usepackageexpl3
usepackagetikz
ExplSyntaxOn
int_new:NmyCounter
int_set:NnmyCounter0
ExplSyntaxOff
tikzset
every node/.style=
/utils/exec=
ExplSyntaxOn
% following line generate an error
% int_incr:NmyCounter
ExplSyntaxOff
begindocument
begintikzpicture
path nodesome text;
endtikzpicture
enddocument
Although block within ExplSyntax does not generate an error, it does not increment myCounter
, causes labels and positioning commands (who knows what else) within tikzset
to generate errors, and prevents a standard counter (myStandardCounter
) from being incremented:
documentclass[varwidth]standalone
usepackageexpl3
usepackagetikz
newcountermyStandardCounter
% let's bring ExplSyntax outside of tikzset and try again
ExplSyntaxOn
int_new:NmyCounter
int_set:NnmyCounter0
tikzset
every node/.style=
/utils/exec=
% neither of the counters below are incremented
int_incr:NmyCounter
stepcountermyStandardCounter
ExplSyntaxOff
begindocument
begintikzpicture
path nodesome text;
endtikzpicture
% both counters are at their initial values (zero)
ExplSyntaxOn
expl3~counter:~int_use:NmyCounter
ExplSyntaxOff
standard counter: thevaluemyStandardCounter
enddocument
tikz-pgf tikz-styles expl3 latex3
tikz-pgf tikz-styles expl3 latex3
asked 6 hours ago
bp2017bp2017
954116
954116
It won't work inside. You have to set the catcodes (i.e.,ExplSyntaxOn
) before the command (tikzset
) reads its argument.
– Phelype Oleinik
6 hours ago
add a comment |
It won't work inside. You have to set the catcodes (i.e.,ExplSyntaxOn
) before the command (tikzset
) reads its argument.
– Phelype Oleinik
6 hours ago
It won't work inside. You have to set the catcodes (i.e.,
ExplSyntaxOn
) before the command (tikzset
) reads its argument.– Phelype Oleinik
6 hours ago
It won't work inside. You have to set the catcodes (i.e.,
ExplSyntaxOn
) before the command (tikzset
) reads its argument.– Phelype Oleinik
6 hours ago
add a comment |
1 Answer
1
active
oldest
votes
First, catcode changes (ExplSyntaxOn
/makeatletter
, ExplSyntaxOff
/makeatother
, and the like) will not work inside macro arguments. TeX turns a input character into a so-called token when it first sees that character. When you do:
tikzset
/utils/exec=
ExplSyntaxOn
int_incr:N myCounter
ExplSyntaxOff
The tikzset
macro grabs everything between and
as argument and, at this point, TeX “sees” those characters, which are turned into tokens using the current catcode regime (with
ExplSyntaxOff
), so int_incr:N myCounter
is tokenized as int
_
i
n
c
r
:
N
myCounter
, and this tokenization is “frozen”, which means you can't change it.
After that the /utils/exec
key does its thing and ExplSyntaxOn
is executed, but at this point it's too late, so it won't work.
Second, using your last code with ExplSyntaxOn
outside. Remember that in the expl3
syntax spaces are ignored, so the every node/.style
key is actually everynode/.style
. And in TikZ spaces do matter. You need every~node/.style
.
And last, you execute the node code inside a tikzpicture
environment, and this creates a bunch of grouping levels, so any local assignment is lost when the endtikzpicture
is reached. You need to use int_gincr:N
to make it work (LaTeX's stepcounter
uses global assignments).
Output:
Working code:
documentclass[varwidth]standalone
usepackageexpl3
usepackagetikz
newcountermyStandardCounter
% let's bring ExplSyntax outside of tikzset and try again
ExplSyntaxOn
int_new:N myCounter
int_gset:Nn myCounter 0
tikzset
every~node/.style=
/utils/exec=
% neither of the counters below are incremented
int_gincr:N myCounter
stepcountermyStandardCounter
ExplSyntaxOff
begindocument
begintikzpicture
path nodesome text;
endtikzpicture
% both counters are at their initial values (zero)
ExplSyntaxOn
expl3~counter:~int_use:NmyCounter
ExplSyntaxOff
standard counter: thevaluemyStandardCounter
enddocument
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
);
);
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%2f491233%2fhow-to-use-explsyntaxon-and-explsyntaxoff-inside-tikzset%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
First, catcode changes (ExplSyntaxOn
/makeatletter
, ExplSyntaxOff
/makeatother
, and the like) will not work inside macro arguments. TeX turns a input character into a so-called token when it first sees that character. When you do:
tikzset
/utils/exec=
ExplSyntaxOn
int_incr:N myCounter
ExplSyntaxOff
The tikzset
macro grabs everything between and
as argument and, at this point, TeX “sees” those characters, which are turned into tokens using the current catcode regime (with
ExplSyntaxOff
), so int_incr:N myCounter
is tokenized as int
_
i
n
c
r
:
N
myCounter
, and this tokenization is “frozen”, which means you can't change it.
After that the /utils/exec
key does its thing and ExplSyntaxOn
is executed, but at this point it's too late, so it won't work.
Second, using your last code with ExplSyntaxOn
outside. Remember that in the expl3
syntax spaces are ignored, so the every node/.style
key is actually everynode/.style
. And in TikZ spaces do matter. You need every~node/.style
.
And last, you execute the node code inside a tikzpicture
environment, and this creates a bunch of grouping levels, so any local assignment is lost when the endtikzpicture
is reached. You need to use int_gincr:N
to make it work (LaTeX's stepcounter
uses global assignments).
Output:
Working code:
documentclass[varwidth]standalone
usepackageexpl3
usepackagetikz
newcountermyStandardCounter
% let's bring ExplSyntax outside of tikzset and try again
ExplSyntaxOn
int_new:N myCounter
int_gset:Nn myCounter 0
tikzset
every~node/.style=
/utils/exec=
% neither of the counters below are incremented
int_gincr:N myCounter
stepcountermyStandardCounter
ExplSyntaxOff
begindocument
begintikzpicture
path nodesome text;
endtikzpicture
% both counters are at their initial values (zero)
ExplSyntaxOn
expl3~counter:~int_use:NmyCounter
ExplSyntaxOff
standard counter: thevaluemyStandardCounter
enddocument
add a comment |
First, catcode changes (ExplSyntaxOn
/makeatletter
, ExplSyntaxOff
/makeatother
, and the like) will not work inside macro arguments. TeX turns a input character into a so-called token when it first sees that character. When you do:
tikzset
/utils/exec=
ExplSyntaxOn
int_incr:N myCounter
ExplSyntaxOff
The tikzset
macro grabs everything between and
as argument and, at this point, TeX “sees” those characters, which are turned into tokens using the current catcode regime (with
ExplSyntaxOff
), so int_incr:N myCounter
is tokenized as int
_
i
n
c
r
:
N
myCounter
, and this tokenization is “frozen”, which means you can't change it.
After that the /utils/exec
key does its thing and ExplSyntaxOn
is executed, but at this point it's too late, so it won't work.
Second, using your last code with ExplSyntaxOn
outside. Remember that in the expl3
syntax spaces are ignored, so the every node/.style
key is actually everynode/.style
. And in TikZ spaces do matter. You need every~node/.style
.
And last, you execute the node code inside a tikzpicture
environment, and this creates a bunch of grouping levels, so any local assignment is lost when the endtikzpicture
is reached. You need to use int_gincr:N
to make it work (LaTeX's stepcounter
uses global assignments).
Output:
Working code:
documentclass[varwidth]standalone
usepackageexpl3
usepackagetikz
newcountermyStandardCounter
% let's bring ExplSyntax outside of tikzset and try again
ExplSyntaxOn
int_new:N myCounter
int_gset:Nn myCounter 0
tikzset
every~node/.style=
/utils/exec=
% neither of the counters below are incremented
int_gincr:N myCounter
stepcountermyStandardCounter
ExplSyntaxOff
begindocument
begintikzpicture
path nodesome text;
endtikzpicture
% both counters are at their initial values (zero)
ExplSyntaxOn
expl3~counter:~int_use:NmyCounter
ExplSyntaxOff
standard counter: thevaluemyStandardCounter
enddocument
add a comment |
First, catcode changes (ExplSyntaxOn
/makeatletter
, ExplSyntaxOff
/makeatother
, and the like) will not work inside macro arguments. TeX turns a input character into a so-called token when it first sees that character. When you do:
tikzset
/utils/exec=
ExplSyntaxOn
int_incr:N myCounter
ExplSyntaxOff
The tikzset
macro grabs everything between and
as argument and, at this point, TeX “sees” those characters, which are turned into tokens using the current catcode regime (with
ExplSyntaxOff
), so int_incr:N myCounter
is tokenized as int
_
i
n
c
r
:
N
myCounter
, and this tokenization is “frozen”, which means you can't change it.
After that the /utils/exec
key does its thing and ExplSyntaxOn
is executed, but at this point it's too late, so it won't work.
Second, using your last code with ExplSyntaxOn
outside. Remember that in the expl3
syntax spaces are ignored, so the every node/.style
key is actually everynode/.style
. And in TikZ spaces do matter. You need every~node/.style
.
And last, you execute the node code inside a tikzpicture
environment, and this creates a bunch of grouping levels, so any local assignment is lost when the endtikzpicture
is reached. You need to use int_gincr:N
to make it work (LaTeX's stepcounter
uses global assignments).
Output:
Working code:
documentclass[varwidth]standalone
usepackageexpl3
usepackagetikz
newcountermyStandardCounter
% let's bring ExplSyntax outside of tikzset and try again
ExplSyntaxOn
int_new:N myCounter
int_gset:Nn myCounter 0
tikzset
every~node/.style=
/utils/exec=
% neither of the counters below are incremented
int_gincr:N myCounter
stepcountermyStandardCounter
ExplSyntaxOff
begindocument
begintikzpicture
path nodesome text;
endtikzpicture
% both counters are at their initial values (zero)
ExplSyntaxOn
expl3~counter:~int_use:NmyCounter
ExplSyntaxOff
standard counter: thevaluemyStandardCounter
enddocument
First, catcode changes (ExplSyntaxOn
/makeatletter
, ExplSyntaxOff
/makeatother
, and the like) will not work inside macro arguments. TeX turns a input character into a so-called token when it first sees that character. When you do:
tikzset
/utils/exec=
ExplSyntaxOn
int_incr:N myCounter
ExplSyntaxOff
The tikzset
macro grabs everything between and
as argument and, at this point, TeX “sees” those characters, which are turned into tokens using the current catcode regime (with
ExplSyntaxOff
), so int_incr:N myCounter
is tokenized as int
_
i
n
c
r
:
N
myCounter
, and this tokenization is “frozen”, which means you can't change it.
After that the /utils/exec
key does its thing and ExplSyntaxOn
is executed, but at this point it's too late, so it won't work.
Second, using your last code with ExplSyntaxOn
outside. Remember that in the expl3
syntax spaces are ignored, so the every node/.style
key is actually everynode/.style
. And in TikZ spaces do matter. You need every~node/.style
.
And last, you execute the node code inside a tikzpicture
environment, and this creates a bunch of grouping levels, so any local assignment is lost when the endtikzpicture
is reached. You need to use int_gincr:N
to make it work (LaTeX's stepcounter
uses global assignments).
Output:
Working code:
documentclass[varwidth]standalone
usepackageexpl3
usepackagetikz
newcountermyStandardCounter
% let's bring ExplSyntax outside of tikzset and try again
ExplSyntaxOn
int_new:N myCounter
int_gset:Nn myCounter 0
tikzset
every~node/.style=
/utils/exec=
% neither of the counters below are incremented
int_gincr:N myCounter
stepcountermyStandardCounter
ExplSyntaxOff
begindocument
begintikzpicture
path nodesome text;
endtikzpicture
% both counters are at their initial values (zero)
ExplSyntaxOn
expl3~counter:~int_use:NmyCounter
ExplSyntaxOff
standard counter: thevaluemyStandardCounter
enddocument
answered 6 hours ago
Phelype OleinikPhelype Oleinik
27.6k54793
27.6k54793
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.
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%2f491233%2fhow-to-use-explsyntaxon-and-explsyntaxoff-inside-tikzset%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
It won't work inside. You have to set the catcodes (i.e.,
ExplSyntaxOn
) before the command (tikzset
) reads its argument.– Phelype Oleinik
6 hours ago