Center align text decoration along path











up vote
3
down vote

favorite
1












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.



enter image description here



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:



enter image description here



Notes:




  • The MWE as is produces the image shown above as the text align=center is 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}









share|improve this question
























  • 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










  • 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










  • @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

















up vote
3
down vote

favorite
1












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.



enter image description here



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:



enter image description here



Notes:




  • The MWE as is produces the image shown above as the text align=center is 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}









share|improve this question
























  • 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










  • 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










  • @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















up vote
3
down vote

favorite
1









up vote
3
down vote

favorite
1






1





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.



enter image description here



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:



enter image description here



Notes:




  • The MWE as is produces the image shown above as the text align=center is 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}









share|improve this question















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.



enter image description here



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:



enter image description here



Notes:




  • The MWE as is produces the image shown above as the text align=center is 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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 1 hour ago

























asked 2 hours ago









Peter Grill

163k24432742




163k24432742












  • 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










  • 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










  • @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




















  • 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










  • 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










  • @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


















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

















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


}
});














 

draft saved


draft discarded


















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






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















 

draft saved


draft discarded



















































 


draft saved


draft discarded














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





















































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

Lallio

Unable to find Lightning Node

Futebolista