verb in label or pin of a tikz node
up vote
4
down vote
favorite
The documentation of tikz gives following example containing the verb
command in the node text (Section 2.21 Adding Text, v3):
begin{tikzpicture}
draw (0,0) rectangle (2,2);
draw (0.5,0.5) node [fill=yellow!80!black]
{Text at verb!node 1!}
-- (1.5,1.5) node {Text at verb!node 2!};
end{tikzpicture}
If I want to use the label or pin functionality for nodes, it does not work as expected:
documentclass[tikz]{standalone}
begin{document}
begin{tikzpicture}
draw (0,0) rectangle (2,2);
draw (0.5,0.5) node [fill=yellow!80!black]
{Text at verb!a_b!}
-- (1.5,1.5) node[label={verb!a_b!}] {Text at verb!a_b!};
end{tikzpicture}
end{document}
The error message given is ! Missing $ inserted.
due to the _
I want to use.
tikz-pgf nodes labels verbatim
add a comment |
up vote
4
down vote
favorite
The documentation of tikz gives following example containing the verb
command in the node text (Section 2.21 Adding Text, v3):
begin{tikzpicture}
draw (0,0) rectangle (2,2);
draw (0.5,0.5) node [fill=yellow!80!black]
{Text at verb!node 1!}
-- (1.5,1.5) node {Text at verb!node 2!};
end{tikzpicture}
If I want to use the label or pin functionality for nodes, it does not work as expected:
documentclass[tikz]{standalone}
begin{document}
begin{tikzpicture}
draw (0,0) rectangle (2,2);
draw (0.5,0.5) node [fill=yellow!80!black]
{Text at verb!a_b!}
-- (1.5,1.5) node[label={verb!a_b!}] {Text at verb!a_b!};
end{tikzpicture}
end{document}
The error message given is ! Missing $ inserted.
due to the _
I want to use.
tikz-pgf nodes labels verbatim
add a comment |
up vote
4
down vote
favorite
up vote
4
down vote
favorite
The documentation of tikz gives following example containing the verb
command in the node text (Section 2.21 Adding Text, v3):
begin{tikzpicture}
draw (0,0) rectangle (2,2);
draw (0.5,0.5) node [fill=yellow!80!black]
{Text at verb!node 1!}
-- (1.5,1.5) node {Text at verb!node 2!};
end{tikzpicture}
If I want to use the label or pin functionality for nodes, it does not work as expected:
documentclass[tikz]{standalone}
begin{document}
begin{tikzpicture}
draw (0,0) rectangle (2,2);
draw (0.5,0.5) node [fill=yellow!80!black]
{Text at verb!a_b!}
-- (1.5,1.5) node[label={verb!a_b!}] {Text at verb!a_b!};
end{tikzpicture}
end{document}
The error message given is ! Missing $ inserted.
due to the _
I want to use.
tikz-pgf nodes labels verbatim
The documentation of tikz gives following example containing the verb
command in the node text (Section 2.21 Adding Text, v3):
begin{tikzpicture}
draw (0,0) rectangle (2,2);
draw (0.5,0.5) node [fill=yellow!80!black]
{Text at verb!node 1!}
-- (1.5,1.5) node {Text at verb!node 2!};
end{tikzpicture}
If I want to use the label or pin functionality for nodes, it does not work as expected:
documentclass[tikz]{standalone}
begin{document}
begin{tikzpicture}
draw (0,0) rectangle (2,2);
draw (0.5,0.5) node [fill=yellow!80!black]
{Text at verb!a_b!}
-- (1.5,1.5) node[label={verb!a_b!}] {Text at verb!a_b!};
end{tikzpicture}
end{document}
The error message given is ! Missing $ inserted.
due to the _
I want to use.
tikz-pgf nodes labels verbatim
tikz-pgf nodes labels verbatim
edited yesterday
asked yesterday
Hotschke
2,06311840
2,06311840
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
up vote
2
down vote
documentclass[tikz]{standalone}
usepackage{fancyvrb} DefineShortVerb{|}
begin{document}
SaveVerb{Verb}|a_b|
begin{tikzpicture}
draw (0,0) rectangle (2,2);
draw (0.5,0.5) node [fill=yellow!80!black]{Text at |a_b|} -- (1.5,1.5)
node[label=UseVerb{Verb}] {Text at |a_b|};
end{tikzpicture}
end{document}
add a comment |
up vote
1
down vote
I really do not fully understand what's going on but I can offer a workaround. To this end, let me first mention that creating a new savebox
and trying it to fill with saveboxverbox{verb!a_b!}
fails. However, a lrbox
works, so I propose to store the content of the label in a savebox
first and then use it.
documentclass[tikz]{standalone}
newsaveboxverbox
begin{document}
begin{lrbox}{verbox}
verb!a_b!
end{lrbox}
% fails:
%saveboxverbox{verb!a_b!}
begin{tikzpicture}
draw (0,0) rectangle (2,2);
draw (0.5,0.5) node [fill=yellow!80!black]
{Text at verb!a_b!}
-- (1.5,1.5) node[label={useboxverbox}] {Text at verb!a_b!};
end{tikzpicture}
end{document}
add a comment |
up vote
1
down vote
Another workaround producing same output as in @marmot answer.
documentclass[tikz]{standalone}
begin{document}
begin{tikzpicture}
draw (0,0) rectangle (2,2);
draw (0.5,0.5) node [fill=yellow!80!black]
{Text at verb!a_b!}
-- (1.5,1.5) node[label=texttt{astring_b}] {Text at verb!a_b!};
end{tikzpicture}
end{document}
texttt{a_b}
should also work
– Herbert
yesterday
1
@Herbert this is what I had done initially but notice that it does not give same result in OT1 default encoding.
– jfbu
yesterday
I cannot see a problem with_$_$
– Herbert
yesterday
1
@Herbert try it out with tt font. I told you it gives different result, and I don't see why I would have said so if not.
– jfbu
yesterday
1
@Herbert I think we have a quiproquo here. I am talking about comparingstring_
with_
. Notice that the OP is asking forverb|a_b|
. You can reproduce same withtexttt{astring_b}
not withtexttt{a_b}
in OT1 encoding.
– jfbu
yesterday
|
show 1 more comment
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
documentclass[tikz]{standalone}
usepackage{fancyvrb} DefineShortVerb{|}
begin{document}
SaveVerb{Verb}|a_b|
begin{tikzpicture}
draw (0,0) rectangle (2,2);
draw (0.5,0.5) node [fill=yellow!80!black]{Text at |a_b|} -- (1.5,1.5)
node[label=UseVerb{Verb}] {Text at |a_b|};
end{tikzpicture}
end{document}
add a comment |
up vote
2
down vote
documentclass[tikz]{standalone}
usepackage{fancyvrb} DefineShortVerb{|}
begin{document}
SaveVerb{Verb}|a_b|
begin{tikzpicture}
draw (0,0) rectangle (2,2);
draw (0.5,0.5) node [fill=yellow!80!black]{Text at |a_b|} -- (1.5,1.5)
node[label=UseVerb{Verb}] {Text at |a_b|};
end{tikzpicture}
end{document}
add a comment |
up vote
2
down vote
up vote
2
down vote
documentclass[tikz]{standalone}
usepackage{fancyvrb} DefineShortVerb{|}
begin{document}
SaveVerb{Verb}|a_b|
begin{tikzpicture}
draw (0,0) rectangle (2,2);
draw (0.5,0.5) node [fill=yellow!80!black]{Text at |a_b|} -- (1.5,1.5)
node[label=UseVerb{Verb}] {Text at |a_b|};
end{tikzpicture}
end{document}
documentclass[tikz]{standalone}
usepackage{fancyvrb} DefineShortVerb{|}
begin{document}
SaveVerb{Verb}|a_b|
begin{tikzpicture}
draw (0,0) rectangle (2,2);
draw (0.5,0.5) node [fill=yellow!80!black]{Text at |a_b|} -- (1.5,1.5)
node[label=UseVerb{Verb}] {Text at |a_b|};
end{tikzpicture}
end{document}
answered yesterday
Herbert
264k23400712
264k23400712
add a comment |
add a comment |
up vote
1
down vote
I really do not fully understand what's going on but I can offer a workaround. To this end, let me first mention that creating a new savebox
and trying it to fill with saveboxverbox{verb!a_b!}
fails. However, a lrbox
works, so I propose to store the content of the label in a savebox
first and then use it.
documentclass[tikz]{standalone}
newsaveboxverbox
begin{document}
begin{lrbox}{verbox}
verb!a_b!
end{lrbox}
% fails:
%saveboxverbox{verb!a_b!}
begin{tikzpicture}
draw (0,0) rectangle (2,2);
draw (0.5,0.5) node [fill=yellow!80!black]
{Text at verb!a_b!}
-- (1.5,1.5) node[label={useboxverbox}] {Text at verb!a_b!};
end{tikzpicture}
end{document}
add a comment |
up vote
1
down vote
I really do not fully understand what's going on but I can offer a workaround. To this end, let me first mention that creating a new savebox
and trying it to fill with saveboxverbox{verb!a_b!}
fails. However, a lrbox
works, so I propose to store the content of the label in a savebox
first and then use it.
documentclass[tikz]{standalone}
newsaveboxverbox
begin{document}
begin{lrbox}{verbox}
verb!a_b!
end{lrbox}
% fails:
%saveboxverbox{verb!a_b!}
begin{tikzpicture}
draw (0,0) rectangle (2,2);
draw (0.5,0.5) node [fill=yellow!80!black]
{Text at verb!a_b!}
-- (1.5,1.5) node[label={useboxverbox}] {Text at verb!a_b!};
end{tikzpicture}
end{document}
add a comment |
up vote
1
down vote
up vote
1
down vote
I really do not fully understand what's going on but I can offer a workaround. To this end, let me first mention that creating a new savebox
and trying it to fill with saveboxverbox{verb!a_b!}
fails. However, a lrbox
works, so I propose to store the content of the label in a savebox
first and then use it.
documentclass[tikz]{standalone}
newsaveboxverbox
begin{document}
begin{lrbox}{verbox}
verb!a_b!
end{lrbox}
% fails:
%saveboxverbox{verb!a_b!}
begin{tikzpicture}
draw (0,0) rectangle (2,2);
draw (0.5,0.5) node [fill=yellow!80!black]
{Text at verb!a_b!}
-- (1.5,1.5) node[label={useboxverbox}] {Text at verb!a_b!};
end{tikzpicture}
end{document}
I really do not fully understand what's going on but I can offer a workaround. To this end, let me first mention that creating a new savebox
and trying it to fill with saveboxverbox{verb!a_b!}
fails. However, a lrbox
works, so I propose to store the content of the label in a savebox
first and then use it.
documentclass[tikz]{standalone}
newsaveboxverbox
begin{document}
begin{lrbox}{verbox}
verb!a_b!
end{lrbox}
% fails:
%saveboxverbox{verb!a_b!}
begin{tikzpicture}
draw (0,0) rectangle (2,2);
draw (0.5,0.5) node [fill=yellow!80!black]
{Text at verb!a_b!}
-- (1.5,1.5) node[label={useboxverbox}] {Text at verb!a_b!};
end{tikzpicture}
end{document}
answered yesterday
marmot
74.6k482157
74.6k482157
add a comment |
add a comment |
up vote
1
down vote
Another workaround producing same output as in @marmot answer.
documentclass[tikz]{standalone}
begin{document}
begin{tikzpicture}
draw (0,0) rectangle (2,2);
draw (0.5,0.5) node [fill=yellow!80!black]
{Text at verb!a_b!}
-- (1.5,1.5) node[label=texttt{astring_b}] {Text at verb!a_b!};
end{tikzpicture}
end{document}
texttt{a_b}
should also work
– Herbert
yesterday
1
@Herbert this is what I had done initially but notice that it does not give same result in OT1 default encoding.
– jfbu
yesterday
I cannot see a problem with_$_$
– Herbert
yesterday
1
@Herbert try it out with tt font. I told you it gives different result, and I don't see why I would have said so if not.
– jfbu
yesterday
1
@Herbert I think we have a quiproquo here. I am talking about comparingstring_
with_
. Notice that the OP is asking forverb|a_b|
. You can reproduce same withtexttt{astring_b}
not withtexttt{a_b}
in OT1 encoding.
– jfbu
yesterday
|
show 1 more comment
up vote
1
down vote
Another workaround producing same output as in @marmot answer.
documentclass[tikz]{standalone}
begin{document}
begin{tikzpicture}
draw (0,0) rectangle (2,2);
draw (0.5,0.5) node [fill=yellow!80!black]
{Text at verb!a_b!}
-- (1.5,1.5) node[label=texttt{astring_b}] {Text at verb!a_b!};
end{tikzpicture}
end{document}
texttt{a_b}
should also work
– Herbert
yesterday
1
@Herbert this is what I had done initially but notice that it does not give same result in OT1 default encoding.
– jfbu
yesterday
I cannot see a problem with_$_$
– Herbert
yesterday
1
@Herbert try it out with tt font. I told you it gives different result, and I don't see why I would have said so if not.
– jfbu
yesterday
1
@Herbert I think we have a quiproquo here. I am talking about comparingstring_
with_
. Notice that the OP is asking forverb|a_b|
. You can reproduce same withtexttt{astring_b}
not withtexttt{a_b}
in OT1 encoding.
– jfbu
yesterday
|
show 1 more comment
up vote
1
down vote
up vote
1
down vote
Another workaround producing same output as in @marmot answer.
documentclass[tikz]{standalone}
begin{document}
begin{tikzpicture}
draw (0,0) rectangle (2,2);
draw (0.5,0.5) node [fill=yellow!80!black]
{Text at verb!a_b!}
-- (1.5,1.5) node[label=texttt{astring_b}] {Text at verb!a_b!};
end{tikzpicture}
end{document}
Another workaround producing same output as in @marmot answer.
documentclass[tikz]{standalone}
begin{document}
begin{tikzpicture}
draw (0,0) rectangle (2,2);
draw (0.5,0.5) node [fill=yellow!80!black]
{Text at verb!a_b!}
-- (1.5,1.5) node[label=texttt{astring_b}] {Text at verb!a_b!};
end{tikzpicture}
end{document}
answered yesterday
jfbu
44.1k65143
44.1k65143
texttt{a_b}
should also work
– Herbert
yesterday
1
@Herbert this is what I had done initially but notice that it does not give same result in OT1 default encoding.
– jfbu
yesterday
I cannot see a problem with_$_$
– Herbert
yesterday
1
@Herbert try it out with tt font. I told you it gives different result, and I don't see why I would have said so if not.
– jfbu
yesterday
1
@Herbert I think we have a quiproquo here. I am talking about comparingstring_
with_
. Notice that the OP is asking forverb|a_b|
. You can reproduce same withtexttt{astring_b}
not withtexttt{a_b}
in OT1 encoding.
– jfbu
yesterday
|
show 1 more comment
texttt{a_b}
should also work
– Herbert
yesterday
1
@Herbert this is what I had done initially but notice that it does not give same result in OT1 default encoding.
– jfbu
yesterday
I cannot see a problem with_$_$
– Herbert
yesterday
1
@Herbert try it out with tt font. I told you it gives different result, and I don't see why I would have said so if not.
– jfbu
yesterday
1
@Herbert I think we have a quiproquo here. I am talking about comparingstring_
with_
. Notice that the OP is asking forverb|a_b|
. You can reproduce same withtexttt{astring_b}
not withtexttt{a_b}
in OT1 encoding.
– jfbu
yesterday
texttt{a_b}
should also work– Herbert
yesterday
texttt{a_b}
should also work– Herbert
yesterday
1
1
@Herbert this is what I had done initially but notice that it does not give same result in OT1 default encoding.
– jfbu
yesterday
@Herbert this is what I had done initially but notice that it does not give same result in OT1 default encoding.
– jfbu
yesterday
I cannot see a problem with
_$_$
– Herbert
yesterday
I cannot see a problem with
_$_$
– Herbert
yesterday
1
1
@Herbert try it out with tt font. I told you it gives different result, and I don't see why I would have said so if not.
– jfbu
yesterday
@Herbert try it out with tt font. I told you it gives different result, and I don't see why I would have said so if not.
– jfbu
yesterday
1
1
@Herbert I think we have a quiproquo here. I am talking about comparing
string_
with _
. Notice that the OP is asking for verb|a_b|
. You can reproduce same with texttt{astring_b}
not with texttt{a_b}
in OT1 encoding.– jfbu
yesterday
@Herbert I think we have a quiproquo here. I am talking about comparing
string_
with _
. Notice that the OP is asking for verb|a_b|
. You can reproduce same with texttt{astring_b}
not with texttt{a_b}
in OT1 encoding.– jfbu
yesterday
|
show 1 more comment
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
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f459592%2fverb-in-label-or-pin-of-a-tikz-node%23new-answer', 'question_page');
}
);
Post as a guest
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
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
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