Center align text decoration along path











up vote
3
down vote

favorite
2












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
    Nov 28 at 20:10










  • 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
    Nov 28 at 20:18










  • 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
    Nov 28 at 20:25










  • @AndréC: Yes, no error, but not quite the results I want. See updated question.
    – Peter Grill
    Nov 28 at 20:41










  • @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
    Nov 28 at 20:42

















up vote
3
down vote

favorite
2












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
    Nov 28 at 20:10










  • 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
    Nov 28 at 20:18










  • 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
    Nov 28 at 20:25










  • @AndréC: Yes, no error, but not quite the results I want. See updated question.
    – Peter Grill
    Nov 28 at 20:41










  • @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
    Nov 28 at 20:42















up vote
3
down vote

favorite
2









up vote
3
down vote

favorite
2






2





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 Nov 28 at 20:40

























asked Nov 28 at 19:46









Peter Grill

163k24432743




163k24432743












  • If you comment on the two lines fill=yellow and rounded corners=2pt, there are no more errors.
    – AndréC
    Nov 28 at 20:10










  • 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
    Nov 28 at 20:18










  • 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
    Nov 28 at 20:25










  • @AndréC: Yes, no error, but not quite the results I want. See updated question.
    – Peter Grill
    Nov 28 at 20:41










  • @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
    Nov 28 at 20:42




















  • If you comment on the two lines fill=yellow and rounded corners=2pt, there are no more errors.
    – AndréC
    Nov 28 at 20:10










  • 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
    Nov 28 at 20:18










  • 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
    Nov 28 at 20:25










  • @AndréC: Yes, no error, but not quite the results I want. See updated question.
    – Peter Grill
    Nov 28 at 20:41










  • @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
    Nov 28 at 20:42


















If you comment on the two lines fill=yellow and rounded corners=2pt, there are no more errors.
– AndréC
Nov 28 at 20:10




If you comment on the two lines fill=yellow and rounded corners=2pt, there are no more errors.
– AndréC
Nov 28 at 20:10












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
Nov 28 at 20:18




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
Nov 28 at 20:18












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
Nov 28 at 20:25




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
Nov 28 at 20:25












@AndréC: Yes, no error, but not quite the results I want. See updated question.
– Peter Grill
Nov 28 at 20:41




@AndréC: Yes, no error, but not quite the results I want. See updated question.
– Peter Grill
Nov 28 at 20:41












@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
Nov 28 at 20:42






@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
Nov 28 at 20:42

















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




















































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.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


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




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

How to change which sound is reproduced for terminal bell?

Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

Can I use Tabulator js library in my java Spring + Thymeleaf project?