In tikz, we can do path replacing decoration with braces.

Is it possible to do this with some other symbol instead? (eg: square bracket). In the manuals, there is no direct method for this is given. I have a feeling that this is not possible directly. I would like to make sure this.

Note that here i am interested in one long symbol as a path: NOT repeated symbols along a path (as in Putting repeated symbols along a path with decorations? ).

May be, something like text along path will do; is it so? (if one can 'kind of rotate' the text along a path, that would suffice). But, I suppose that would be hard to do.

Thank you

update: @marmot's answer was an eye-opener. After all, the idea of having a rotated text stretched along a path may not work. I thank @marmot for the effort he put in (i can never do latex code like that :< ). Yet, the stretching of the symbol this way kills it as pointed out by @sebastiano. But, for some symbols there may be better ways to do it. For example, this question for square brackets: Is there a TikZ equivalent to the PSTricks \ncbar command? as pointed out by @marmot in his answer.

  • The answer to the question "Is it possible to use some symbol other than braces for path decoration?" is "Yes, if you are willing to define such a decoration.". A square bracket is almost trivial, other symbols may be more challenging. If you ask a concrete question of the sort "How can one get square brackets instead of braces?", I guess you will get an answer with a code. – user121799 Dec 17 '18 at 20:50
  • Am I using @ symbol wrong here? If so, please let me know. This one got me confused. – Cyriac Antony Dec 18 '18 at 5:20

I do not know if that is the answer you are looking for but of course you can replace any straight line by a symbol that gets stretched accordingly. (Of course this won't produce nice looking braces or brackets. Nice brackets can be produced with this answer, and nice braces can be made using decorations.pathreplacing, as you pointed out yourself.)

\tikzset{replace path by symbol/.style={to path={%
in \pgfextra{\pgfmathsetmacro{\mywidth}{width("#1")}
(\tikztotarget) -- (\tikztostart) node [midway,sloped,xscale=\n2]{#1}
replace path by rotated symbol/.style={to path={%
in \pgfextra{\pgfmathsetmacro{\mywidth}{width("#1")}
(\tikztotarget) -- (\tikztostart) node [midway,sloped,rotate=90,yscale=\n2]{#1}
\path (0,0) coordinate (A) (2,1) coordinate (B) (4,0) coordinate (C) (6,1) coordinate (D);
\path[replace path by symbol=t] (A) to (B);
\path[replace path by rotated symbol={]}] (C) to (D);

enter image description here

| improve this answer | |
  • What is this? :-) An antenna? You know how much the left image looks like a car wiper blade? :) – Sebastiano Dec 17 '18 at 21:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.