Center align text decoration along path
up vote
3
down vote
favorite
I am trying to duplicate the node highlighted in green but along a curved path. It mostly works, but when I attempt to apply the text align=center effect to the decoration, I get
Dimension too large.
I get pretty good results if I set defRadius{2.8cm}.
But, if I set defRadius{2.6cm}, then I get the same error as above. This I suspect is due to the fact that the text can no longer fit along the given path.
To avoid this problem in the future, if I can get the text align=center to work, I can provide a pathwhich is more than sufficient to place the text and draw the node separately.

As per AndreC's comment, commenting out the fill=yellow and rounded corners=2pt:
draw [draw=red,
postaction={
decoration={
text along path,
text={|+tinyscshape|MyText},
raise=0.5ex,
text align=center,% <---- Uncommented
},
decorate,
},
%% No error with these commented, but results are wack!!
%fill=yellow,
%rounded corners=2pt,
]
no longer results in an error. However, with this I get the following:

Notes:
- The MWE as is produces the image shown above as the
text align=centeris commented out. To get the railing case, that needs to be uncommented.
Code:
documentclass{article}
usepackage{tikz}
usetikzlibrary{decorations}
usetikzlibrary{decorations.text}
newcommand{MyText}{ABCDEF}
tikzset{My Node Style/.style={
fill=green,
draw=red,
inner sep=2pt,
rounded corners=2pt,
font=tiny,
}}
begin{document}
begin{tikzpicture}
node [My Node Style] at (0,2.5) {textsc{MyText}};
defRadius{3.0cm}
defStartAngle{100}
defEndAngle{80}
defNodeThickness{1.6ex}
draw [draw=red,
postaction={
decoration={
text along path,
text={|+tinyscshape|MyText},
raise=0.5ex,
%text align=center,% <---- ????? Dimension too big ?????
},
decorate,
},
fill=yellow,
rounded corners=2pt,
]
([shift={(StartAngle:Radius)}]0,0)
arc [start angle=StartAngle, end angle=EndAngle, radius=Radius]
-- ++(EndAngle:NodeThickness)
arc [start angle=EndAngle, end angle=StartAngle, radius=Radius+NodeThickness]
-- cycle
;
end{tikzpicture}
end{document}
tikz-pgf nodes text-decorations rounded-corners
|
show 4 more comments
up vote
3
down vote
favorite
I am trying to duplicate the node highlighted in green but along a curved path. It mostly works, but when I attempt to apply the text align=center effect to the decoration, I get
Dimension too large.
I get pretty good results if I set defRadius{2.8cm}.
But, if I set defRadius{2.6cm}, then I get the same error as above. This I suspect is due to the fact that the text can no longer fit along the given path.
To avoid this problem in the future, if I can get the text align=center to work, I can provide a pathwhich is more than sufficient to place the text and draw the node separately.

As per AndreC's comment, commenting out the fill=yellow and rounded corners=2pt:
draw [draw=red,
postaction={
decoration={
text along path,
text={|+tinyscshape|MyText},
raise=0.5ex,
text align=center,% <---- Uncommented
},
decorate,
},
%% No error with these commented, but results are wack!!
%fill=yellow,
%rounded corners=2pt,
]
no longer results in an error. However, with this I get the following:

Notes:
- The MWE as is produces the image shown above as the
text align=centeris commented out. To get the railing case, that needs to be uncommented.
Code:
documentclass{article}
usepackage{tikz}
usetikzlibrary{decorations}
usetikzlibrary{decorations.text}
newcommand{MyText}{ABCDEF}
tikzset{My Node Style/.style={
fill=green,
draw=red,
inner sep=2pt,
rounded corners=2pt,
font=tiny,
}}
begin{document}
begin{tikzpicture}
node [My Node Style] at (0,2.5) {textsc{MyText}};
defRadius{3.0cm}
defStartAngle{100}
defEndAngle{80}
defNodeThickness{1.6ex}
draw [draw=red,
postaction={
decoration={
text along path,
text={|+tinyscshape|MyText},
raise=0.5ex,
%text align=center,% <---- ????? Dimension too big ?????
},
decorate,
},
fill=yellow,
rounded corners=2pt,
]
([shift={(StartAngle:Radius)}]0,0)
arc [start angle=StartAngle, end angle=EndAngle, radius=Radius]
-- ++(EndAngle:NodeThickness)
arc [start angle=EndAngle, end angle=StartAngle, radius=Radius+NodeThickness]
-- cycle
;
end{tikzpicture}
end{document}
tikz-pgf nodes text-decorations rounded-corners
If you comment on the two linesfill=yellowandrounded corners=2pt, there are no more errors.
– AndréC
2 hours ago
You could just measure the width of the text and then adjustStartAngleandEndAngleto be such that the text is centered. (Of course, this will make the node smaller.)
– marmot
2 hours ago
There is no error withtext align=left, but there is one withtext align=right, would that be a bug with these key?
– AndréC
2 hours ago
@AndréC: Yes, no error, but not quite the results I want. See updated question.
– Peter Grill
1 hour ago
@marmot: Yep, that was the comment regarding usingdefRadius{2.8cm}. However, if the text changes in the future it'll take time for me to figure out what is going on, so would prefer a more robust solution.
– Peter Grill
1 hour ago
|
show 4 more comments
up vote
3
down vote
favorite
up vote
3
down vote
favorite
I am trying to duplicate the node highlighted in green but along a curved path. It mostly works, but when I attempt to apply the text align=center effect to the decoration, I get
Dimension too large.
I get pretty good results if I set defRadius{2.8cm}.
But, if I set defRadius{2.6cm}, then I get the same error as above. This I suspect is due to the fact that the text can no longer fit along the given path.
To avoid this problem in the future, if I can get the text align=center to work, I can provide a pathwhich is more than sufficient to place the text and draw the node separately.

As per AndreC's comment, commenting out the fill=yellow and rounded corners=2pt:
draw [draw=red,
postaction={
decoration={
text along path,
text={|+tinyscshape|MyText},
raise=0.5ex,
text align=center,% <---- Uncommented
},
decorate,
},
%% No error with these commented, but results are wack!!
%fill=yellow,
%rounded corners=2pt,
]
no longer results in an error. However, with this I get the following:

Notes:
- The MWE as is produces the image shown above as the
text align=centeris commented out. To get the railing case, that needs to be uncommented.
Code:
documentclass{article}
usepackage{tikz}
usetikzlibrary{decorations}
usetikzlibrary{decorations.text}
newcommand{MyText}{ABCDEF}
tikzset{My Node Style/.style={
fill=green,
draw=red,
inner sep=2pt,
rounded corners=2pt,
font=tiny,
}}
begin{document}
begin{tikzpicture}
node [My Node Style] at (0,2.5) {textsc{MyText}};
defRadius{3.0cm}
defStartAngle{100}
defEndAngle{80}
defNodeThickness{1.6ex}
draw [draw=red,
postaction={
decoration={
text along path,
text={|+tinyscshape|MyText},
raise=0.5ex,
%text align=center,% <---- ????? Dimension too big ?????
},
decorate,
},
fill=yellow,
rounded corners=2pt,
]
([shift={(StartAngle:Radius)}]0,0)
arc [start angle=StartAngle, end angle=EndAngle, radius=Radius]
-- ++(EndAngle:NodeThickness)
arc [start angle=EndAngle, end angle=StartAngle, radius=Radius+NodeThickness]
-- cycle
;
end{tikzpicture}
end{document}
tikz-pgf nodes text-decorations rounded-corners
I am trying to duplicate the node highlighted in green but along a curved path. It mostly works, but when I attempt to apply the text align=center effect to the decoration, I get
Dimension too large.
I get pretty good results if I set defRadius{2.8cm}.
But, if I set defRadius{2.6cm}, then I get the same error as above. This I suspect is due to the fact that the text can no longer fit along the given path.
To avoid this problem in the future, if I can get the text align=center to work, I can provide a pathwhich is more than sufficient to place the text and draw the node separately.

As per AndreC's comment, commenting out the fill=yellow and rounded corners=2pt:
draw [draw=red,
postaction={
decoration={
text along path,
text={|+tinyscshape|MyText},
raise=0.5ex,
text align=center,% <---- Uncommented
},
decorate,
},
%% No error with these commented, but results are wack!!
%fill=yellow,
%rounded corners=2pt,
]
no longer results in an error. However, with this I get the following:

Notes:
- The MWE as is produces the image shown above as the
text align=centeris commented out. To get the railing case, that needs to be uncommented.
Code:
documentclass{article}
usepackage{tikz}
usetikzlibrary{decorations}
usetikzlibrary{decorations.text}
newcommand{MyText}{ABCDEF}
tikzset{My Node Style/.style={
fill=green,
draw=red,
inner sep=2pt,
rounded corners=2pt,
font=tiny,
}}
begin{document}
begin{tikzpicture}
node [My Node Style] at (0,2.5) {textsc{MyText}};
defRadius{3.0cm}
defStartAngle{100}
defEndAngle{80}
defNodeThickness{1.6ex}
draw [draw=red,
postaction={
decoration={
text along path,
text={|+tinyscshape|MyText},
raise=0.5ex,
%text align=center,% <---- ????? Dimension too big ?????
},
decorate,
},
fill=yellow,
rounded corners=2pt,
]
([shift={(StartAngle:Radius)}]0,0)
arc [start angle=StartAngle, end angle=EndAngle, radius=Radius]
-- ++(EndAngle:NodeThickness)
arc [start angle=EndAngle, end angle=StartAngle, radius=Radius+NodeThickness]
-- cycle
;
end{tikzpicture}
end{document}
tikz-pgf nodes text-decorations rounded-corners
tikz-pgf nodes text-decorations rounded-corners
edited 1 hour ago
asked 2 hours ago
Peter Grill
163k24432742
163k24432742
If you comment on the two linesfill=yellowandrounded corners=2pt, there are no more errors.
– AndréC
2 hours ago
You could just measure the width of the text and then adjustStartAngleandEndAngleto be such that the text is centered. (Of course, this will make the node smaller.)
– marmot
2 hours ago
There is no error withtext align=left, but there is one withtext align=right, would that be a bug with these key?
– AndréC
2 hours ago
@AndréC: Yes, no error, but not quite the results I want. See updated question.
– Peter Grill
1 hour ago
@marmot: Yep, that was the comment regarding usingdefRadius{2.8cm}. However, if the text changes in the future it'll take time for me to figure out what is going on, so would prefer a more robust solution.
– Peter Grill
1 hour ago
|
show 4 more comments
If you comment on the two linesfill=yellowandrounded corners=2pt, there are no more errors.
– AndréC
2 hours ago
You could just measure the width of the text and then adjustStartAngleandEndAngleto be such that the text is centered. (Of course, this will make the node smaller.)
– marmot
2 hours ago
There is no error withtext align=left, but there is one withtext align=right, would that be a bug with these key?
– AndréC
2 hours ago
@AndréC: Yes, no error, but not quite the results I want. See updated question.
– Peter Grill
1 hour ago
@marmot: Yep, that was the comment regarding usingdefRadius{2.8cm}. However, if the text changes in the future it'll take time for me to figure out what is going on, so would prefer a more robust solution.
– Peter Grill
1 hour ago
If you comment on the two lines
fill=yellow and rounded corners=2pt, there are no more errors.– AndréC
2 hours ago
If you comment on the two lines
fill=yellow and rounded corners=2pt, there are no more errors.– AndréC
2 hours ago
You could just measure the width of the text and then adjust
StartAngle and EndAngle to be such that the text is centered. (Of course, this will make the node smaller.)– marmot
2 hours ago
You could just measure the width of the text and then adjust
StartAngle and EndAngle to be such that the text is centered. (Of course, this will make the node smaller.)– marmot
2 hours ago
There is no error with
text align=left, but there is one with text align=right, would that be a bug with these key?– AndréC
2 hours ago
There is no error with
text align=left, but there is one with text align=right, would that be a bug with these key?– AndréC
2 hours ago
@AndréC: Yes, no error, but not quite the results I want. See updated question.
– Peter Grill
1 hour ago
@AndréC: Yes, no error, but not quite the results I want. See updated question.
– Peter Grill
1 hour ago
@marmot: Yep, that was the comment regarding using
defRadius{2.8cm}. However, if the text changes in the future it'll take time for me to figure out what is going on, so would prefer a more robust solution.– Peter Grill
1 hour ago
@marmot: Yep, that was the comment regarding using
defRadius{2.8cm}. However, if the text changes in the future it'll take time for me to figure out what is going on, so would prefer a more robust solution.– Peter Grill
1 hour ago
|
show 4 more comments
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
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%2f462237%2fcenter-align-text-decoration-along-path%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
If you comment on the two lines
fill=yellowandrounded corners=2pt, there are no more errors.– AndréC
2 hours ago
You could just measure the width of the text and then adjust
StartAngleandEndAngleto be such that the text is centered. (Of course, this will make the node smaller.)– marmot
2 hours ago
There is no error with
text align=left, but there is one withtext align=right, would that be a bug with these key?– AndréC
2 hours ago
@AndréC: Yes, no error, but not quite the results I want. See updated question.
– Peter Grill
1 hour ago
@marmot: Yep, that was the comment regarding using
defRadius{2.8cm}. However, if the text changes in the future it'll take time for me to figure out what is going on, so would prefer a more robust solution.– Peter Grill
1 hour ago