text subscript size in tikzmath macro is not correct

Clash Royale CLAN TAG#URR8PPP
This question is related to this earlier TeX-SE question of mine
I would like to have a proper text subscript using the text command. It does not seem to work with the tikzmath macros. Please see the following MWW:
documentclassstandalone
usepackageamsmath
usepackagetikz
usetikzlibrarymath
%%%To fix the text subscript
%usepackageetoolbox
%makeatletter
%robustifytext
%makeatother
begindocument
begintikzpicture
node at (0,0) $textb_textb$: Correct;
tikzmathlet test=textb_textb;
node at (0,-1cm) $test$: Not Correct;
endtikzpicture
enddocument
As can be seen from the output, the subscript size is not correct:
If I apply the suggest fix, the subscript size is corrected:
My question is the use of etoolbox and robustify the suggested way of fixing the text subscripts, which may have some side effects that I may face in the future, or is there a more robust way of correcting the size?
Note: Use of textrm does not work in the above example, which I used for the problem I have reported in my earlier post.
tikz-pgf tikzmath
add a comment |
This question is related to this earlier TeX-SE question of mine
I would like to have a proper text subscript using the text command. It does not seem to work with the tikzmath macros. Please see the following MWW:
documentclassstandalone
usepackageamsmath
usepackagetikz
usetikzlibrarymath
%%%To fix the text subscript
%usepackageetoolbox
%makeatletter
%robustifytext
%makeatother
begindocument
begintikzpicture
node at (0,0) $textb_textb$: Correct;
tikzmathlet test=textb_textb;
node at (0,-1cm) $test$: Not Correct;
endtikzpicture
enddocument
As can be seen from the output, the subscript size is not correct:
If I apply the suggest fix, the subscript size is corrected:
My question is the use of etoolbox and robustify the suggested way of fixing the text subscripts, which may have some side effects that I may face in the future, or is there a more robust way of correcting the size?
Note: Use of textrm does not work in the above example, which I used for the problem I have reported in my earlier post.
tikz-pgf tikzmath
There should be an additional set of braces aroundtextbfor semantic reasons:b_textb
– Skillmon
Feb 20 at 18:01
@Skillmon: Yes! Exactly! Without braces I have experienced some issues in some tikzmath operations. Thanks for noting this.
– berkus
Feb 20 at 18:06
What's the reason fortikzmath? Isn'tdeftesttextb_textbsufficient?
– egreg
Feb 20 at 18:17
@egreg I have been usingtikzmathfor writing some tikz parametric packages, which I have to define manytikzmathmacros.
– berkus
Feb 20 at 18:24
add a comment |
This question is related to this earlier TeX-SE question of mine
I would like to have a proper text subscript using the text command. It does not seem to work with the tikzmath macros. Please see the following MWW:
documentclassstandalone
usepackageamsmath
usepackagetikz
usetikzlibrarymath
%%%To fix the text subscript
%usepackageetoolbox
%makeatletter
%robustifytext
%makeatother
begindocument
begintikzpicture
node at (0,0) $textb_textb$: Correct;
tikzmathlet test=textb_textb;
node at (0,-1cm) $test$: Not Correct;
endtikzpicture
enddocument
As can be seen from the output, the subscript size is not correct:
If I apply the suggest fix, the subscript size is corrected:
My question is the use of etoolbox and robustify the suggested way of fixing the text subscripts, which may have some side effects that I may face in the future, or is there a more robust way of correcting the size?
Note: Use of textrm does not work in the above example, which I used for the problem I have reported in my earlier post.
tikz-pgf tikzmath
This question is related to this earlier TeX-SE question of mine
I would like to have a proper text subscript using the text command. It does not seem to work with the tikzmath macros. Please see the following MWW:
documentclassstandalone
usepackageamsmath
usepackagetikz
usetikzlibrarymath
%%%To fix the text subscript
%usepackageetoolbox
%makeatletter
%robustifytext
%makeatother
begindocument
begintikzpicture
node at (0,0) $textb_textb$: Correct;
tikzmathlet test=textb_textb;
node at (0,-1cm) $test$: Not Correct;
endtikzpicture
enddocument
As can be seen from the output, the subscript size is not correct:
If I apply the suggest fix, the subscript size is corrected:
My question is the use of etoolbox and robustify the suggested way of fixing the text subscripts, which may have some side effects that I may face in the future, or is there a more robust way of correcting the size?
Note: Use of textrm does not work in the above example, which I used for the problem I have reported in my earlier post.
tikz-pgf tikzmath
tikz-pgf tikzmath
edited Feb 20 at 18:12
Bernard
173k776204
173k776204
asked Feb 20 at 17:43
berkusberkus
654317
654317
There should be an additional set of braces aroundtextbfor semantic reasons:b_textb
– Skillmon
Feb 20 at 18:01
@Skillmon: Yes! Exactly! Without braces I have experienced some issues in some tikzmath operations. Thanks for noting this.
– berkus
Feb 20 at 18:06
What's the reason fortikzmath? Isn'tdeftesttextb_textbsufficient?
– egreg
Feb 20 at 18:17
@egreg I have been usingtikzmathfor writing some tikz parametric packages, which I have to define manytikzmathmacros.
– berkus
Feb 20 at 18:24
add a comment |
There should be an additional set of braces aroundtextbfor semantic reasons:b_textb
– Skillmon
Feb 20 at 18:01
@Skillmon: Yes! Exactly! Without braces I have experienced some issues in some tikzmath operations. Thanks for noting this.
– berkus
Feb 20 at 18:06
What's the reason fortikzmath? Isn'tdeftesttextb_textbsufficient?
– egreg
Feb 20 at 18:17
@egreg I have been usingtikzmathfor writing some tikz parametric packages, which I have to define manytikzmathmacros.
– berkus
Feb 20 at 18:24
There should be an additional set of braces around
textb for semantic reasons: b_textb– Skillmon
Feb 20 at 18:01
There should be an additional set of braces around
textb for semantic reasons: b_textb– Skillmon
Feb 20 at 18:01
@Skillmon: Yes! Exactly! Without braces I have experienced some issues in some tikzmath operations. Thanks for noting this.
– berkus
Feb 20 at 18:06
@Skillmon: Yes! Exactly! Without braces I have experienced some issues in some tikzmath operations. Thanks for noting this.
– berkus
Feb 20 at 18:06
What's the reason for
tikzmath? Isn't deftesttextb_textb sufficient?– egreg
Feb 20 at 18:17
What's the reason for
tikzmath? Isn't deftesttextb_textb sufficient?– egreg
Feb 20 at 18:17
@egreg I have been using
tikzmath for writing some tikz parametric packages, which I have to define many tikzmath macros.– berkus
Feb 20 at 18:24
@egreg I have been using
tikzmath for writing some tikz parametric packages, which I have to define many tikzmath macros.– berkus
Feb 20 at 18:24
add a comment |
2 Answers
2
active
oldest
votes
Add a noexpand can fix it directly. But I would think the robustify approach makes more sense if this is an ongoing issue.
documentclassstandalone
usepackageamsmath
usepackagetikz
usetikzlibrarymath
%%%To fix the text subscript
%usepackageetoolbox
%makeatletter
%robustifytext
%makeatother
begindocument
begintikzpicture
node at (0,0) $textb_textb$: Correct;
tikzmathlet test=textb_textb;
node at (0,-1cm) $test$: Not Correct;
tikzmathlet test=textb_noexpandtextb;
node at (0,-2cm) $test$: Corrected with noexpand;
endtikzpicture
enddocument

The screenshot doesn't reflect the real output (in my output, with TeX live 2018, the $b_b$ in the middle is the same as the $b_b$ in the top, and therefor "is correct").
– quark67
Feb 20 at 18:44
add a comment |
You can see what's going on if you add showtext after the tikzmath declaration:
> test=macro:
->protect unhbox voidb@x hbox b_protect unhbox voidb@x hbox b.
Indeed, the definition of text is found in amstext.sty:
% amstext.sty, line 28:
DeclareRobustCommandtext%
ifmmodeexpandaftertext@elseexpandaftermboxfi
You also have to know that tikzmath does full expansion; since text is not found in math mode, it just does mbox. Since at the time of let the meaning of protect is relax, it goes on untouched; then the conditional is expanded and since TeX is not in math mode, you get mboxb, which becomes
leavemodehboxb
and finally unhboxvoidb@xhboxb. This should explain the output of show above.
Possibly you want to evaluate something instead of having b in the argument to text; in this case you need to be careful about what to fully expand and what not.
tikzmathlet test=noexpandtextb_noexpandtextb;
will do, but if instead of b you have something like textbfabc, this will die horribly anyhow.
You need noexpand in front of both occurrences of text, in order to suppress its expansion and get the right version when test is indeed used in math mode.
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%2f475866%2ftext-subscript-size-in-tikzmath-macro-is-not-correct%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
Add a noexpand can fix it directly. But I would think the robustify approach makes more sense if this is an ongoing issue.
documentclassstandalone
usepackageamsmath
usepackagetikz
usetikzlibrarymath
%%%To fix the text subscript
%usepackageetoolbox
%makeatletter
%robustifytext
%makeatother
begindocument
begintikzpicture
node at (0,0) $textb_textb$: Correct;
tikzmathlet test=textb_textb;
node at (0,-1cm) $test$: Not Correct;
tikzmathlet test=textb_noexpandtextb;
node at (0,-2cm) $test$: Corrected with noexpand;
endtikzpicture
enddocument

The screenshot doesn't reflect the real output (in my output, with TeX live 2018, the $b_b$ in the middle is the same as the $b_b$ in the top, and therefor "is correct").
– quark67
Feb 20 at 18:44
add a comment |
Add a noexpand can fix it directly. But I would think the robustify approach makes more sense if this is an ongoing issue.
documentclassstandalone
usepackageamsmath
usepackagetikz
usetikzlibrarymath
%%%To fix the text subscript
%usepackageetoolbox
%makeatletter
%robustifytext
%makeatother
begindocument
begintikzpicture
node at (0,0) $textb_textb$: Correct;
tikzmathlet test=textb_textb;
node at (0,-1cm) $test$: Not Correct;
tikzmathlet test=textb_noexpandtextb;
node at (0,-2cm) $test$: Corrected with noexpand;
endtikzpicture
enddocument

The screenshot doesn't reflect the real output (in my output, with TeX live 2018, the $b_b$ in the middle is the same as the $b_b$ in the top, and therefor "is correct").
– quark67
Feb 20 at 18:44
add a comment |
Add a noexpand can fix it directly. But I would think the robustify approach makes more sense if this is an ongoing issue.
documentclassstandalone
usepackageamsmath
usepackagetikz
usetikzlibrarymath
%%%To fix the text subscript
%usepackageetoolbox
%makeatletter
%robustifytext
%makeatother
begindocument
begintikzpicture
node at (0,0) $textb_textb$: Correct;
tikzmathlet test=textb_textb;
node at (0,-1cm) $test$: Not Correct;
tikzmathlet test=textb_noexpandtextb;
node at (0,-2cm) $test$: Corrected with noexpand;
endtikzpicture
enddocument

Add a noexpand can fix it directly. But I would think the robustify approach makes more sense if this is an ongoing issue.
documentclassstandalone
usepackageamsmath
usepackagetikz
usetikzlibrarymath
%%%To fix the text subscript
%usepackageetoolbox
%makeatletter
%robustifytext
%makeatother
begindocument
begintikzpicture
node at (0,0) $textb_textb$: Correct;
tikzmathlet test=textb_textb;
node at (0,-1cm) $test$: Not Correct;
tikzmathlet test=textb_noexpandtextb;
node at (0,-2cm) $test$: Corrected with noexpand;
endtikzpicture
enddocument

edited Feb 21 at 6:33
berkus
654317
654317
answered Feb 20 at 17:47
Steven B. SegletesSteven B. Segletes
158k9204411
158k9204411
The screenshot doesn't reflect the real output (in my output, with TeX live 2018, the $b_b$ in the middle is the same as the $b_b$ in the top, and therefor "is correct").
– quark67
Feb 20 at 18:44
add a comment |
The screenshot doesn't reflect the real output (in my output, with TeX live 2018, the $b_b$ in the middle is the same as the $b_b$ in the top, and therefor "is correct").
– quark67
Feb 20 at 18:44
The screenshot doesn't reflect the real output (in my output, with TeX live 2018, the $b_b$ in the middle is the same as the $b_b$ in the top, and therefor "is correct").
– quark67
Feb 20 at 18:44
The screenshot doesn't reflect the real output (in my output, with TeX live 2018, the $b_b$ in the middle is the same as the $b_b$ in the top, and therefor "is correct").
– quark67
Feb 20 at 18:44
add a comment |
You can see what's going on if you add showtext after the tikzmath declaration:
> test=macro:
->protect unhbox voidb@x hbox b_protect unhbox voidb@x hbox b.
Indeed, the definition of text is found in amstext.sty:
% amstext.sty, line 28:
DeclareRobustCommandtext%
ifmmodeexpandaftertext@elseexpandaftermboxfi
You also have to know that tikzmath does full expansion; since text is not found in math mode, it just does mbox. Since at the time of let the meaning of protect is relax, it goes on untouched; then the conditional is expanded and since TeX is not in math mode, you get mboxb, which becomes
leavemodehboxb
and finally unhboxvoidb@xhboxb. This should explain the output of show above.
Possibly you want to evaluate something instead of having b in the argument to text; in this case you need to be careful about what to fully expand and what not.
tikzmathlet test=noexpandtextb_noexpandtextb;
will do, but if instead of b you have something like textbfabc, this will die horribly anyhow.
You need noexpand in front of both occurrences of text, in order to suppress its expansion and get the right version when test is indeed used in math mode.
add a comment |
You can see what's going on if you add showtext after the tikzmath declaration:
> test=macro:
->protect unhbox voidb@x hbox b_protect unhbox voidb@x hbox b.
Indeed, the definition of text is found in amstext.sty:
% amstext.sty, line 28:
DeclareRobustCommandtext%
ifmmodeexpandaftertext@elseexpandaftermboxfi
You also have to know that tikzmath does full expansion; since text is not found in math mode, it just does mbox. Since at the time of let the meaning of protect is relax, it goes on untouched; then the conditional is expanded and since TeX is not in math mode, you get mboxb, which becomes
leavemodehboxb
and finally unhboxvoidb@xhboxb. This should explain the output of show above.
Possibly you want to evaluate something instead of having b in the argument to text; in this case you need to be careful about what to fully expand and what not.
tikzmathlet test=noexpandtextb_noexpandtextb;
will do, but if instead of b you have something like textbfabc, this will die horribly anyhow.
You need noexpand in front of both occurrences of text, in order to suppress its expansion and get the right version when test is indeed used in math mode.
add a comment |
You can see what's going on if you add showtext after the tikzmath declaration:
> test=macro:
->protect unhbox voidb@x hbox b_protect unhbox voidb@x hbox b.
Indeed, the definition of text is found in amstext.sty:
% amstext.sty, line 28:
DeclareRobustCommandtext%
ifmmodeexpandaftertext@elseexpandaftermboxfi
You also have to know that tikzmath does full expansion; since text is not found in math mode, it just does mbox. Since at the time of let the meaning of protect is relax, it goes on untouched; then the conditional is expanded and since TeX is not in math mode, you get mboxb, which becomes
leavemodehboxb
and finally unhboxvoidb@xhboxb. This should explain the output of show above.
Possibly you want to evaluate something instead of having b in the argument to text; in this case you need to be careful about what to fully expand and what not.
tikzmathlet test=noexpandtextb_noexpandtextb;
will do, but if instead of b you have something like textbfabc, this will die horribly anyhow.
You need noexpand in front of both occurrences of text, in order to suppress its expansion and get the right version when test is indeed used in math mode.
You can see what's going on if you add showtext after the tikzmath declaration:
> test=macro:
->protect unhbox voidb@x hbox b_protect unhbox voidb@x hbox b.
Indeed, the definition of text is found in amstext.sty:
% amstext.sty, line 28:
DeclareRobustCommandtext%
ifmmodeexpandaftertext@elseexpandaftermboxfi
You also have to know that tikzmath does full expansion; since text is not found in math mode, it just does mbox. Since at the time of let the meaning of protect is relax, it goes on untouched; then the conditional is expanded and since TeX is not in math mode, you get mboxb, which becomes
leavemodehboxb
and finally unhboxvoidb@xhboxb. This should explain the output of show above.
Possibly you want to evaluate something instead of having b in the argument to text; in this case you need to be careful about what to fully expand and what not.
tikzmathlet test=noexpandtextb_noexpandtextb;
will do, but if instead of b you have something like textbfabc, this will die horribly anyhow.
You need noexpand in front of both occurrences of text, in order to suppress its expansion and get the right version when test is indeed used in math mode.
edited Feb 21 at 6:37
Peter Grill
166k25442756
166k25442756
answered Feb 20 at 18:24
egregegreg
727k8819223231
727k8819223231
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%2f475866%2ftext-subscript-size-in-tikzmath-macro-is-not-correct%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
There should be an additional set of braces around
textbfor semantic reasons:b_textb– Skillmon
Feb 20 at 18:01
@Skillmon: Yes! Exactly! Without braces I have experienced some issues in some tikzmath operations. Thanks for noting this.
– berkus
Feb 20 at 18:06
What's the reason for
tikzmath? Isn'tdeftesttextb_textbsufficient?– egreg
Feb 20 at 18:17
@egreg I have been using
tikzmathfor writing some tikz parametric packages, which I have to define manytikzmathmacros.– berkus
Feb 20 at 18:24