Let's say I have the following string list of symbol: {a,b,+,9,3}.
Is there a way to print each element of this list with the possibility - EDIT 1: to control the space between each symbol and - to change some property (e.g. the rotate angle or color shade) and all this using pic and decoration if possible?
So, with this kind of code (1,2):
\documentclass[tikz]{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.markings,positioning}
\tikzset{%
symbols/.pic={% https://tex.stackexchange.com/a/350347/262081
\node{a,b,+,9,3};% Not working !!!!!!!!!!!!!!!!!!!
},%
inlinesymbols/.style={%
decoration={%
markings,%
mark =%
between positions 0 and 1 step 5mm % adjust step size here
with {{\pgfmathsetmacro{\myangle}{360*rnd}%
\pic[rotate=\myangle] {symbols};}% https://tex.stackexchange.com/a/576704/262081
}%
},%
postaction={decorate}%
},%
}%
\begin{document}
\begin{tikzpicture}
\path[inlinesymbols] (0,0) -- (2,0);%
\end{tikzpicture}
\end{document}
I would like to obtain something like this:
With the horizontal space between each symbol set for e.g. by decoration mark step (set to 5mm in the exemple above) or something else.
If it's not possible with a Tikz decoration or even a pic I'm also aware of alternative ways but with the possibility of changing some parameters (as the rotation angle) if possible.
EDIT 2: Why I want that ?
I would like to be able to inline (horizontally) draw a list of symbol regardless of the number of elements in this list and with the possibility of controling the space between each symbol and some property (e.g. rotation, shade, color) set for all symbol (i.e. the property is aplied to all symbols globally).
So, the use of Tikz pics and decoration are not mandatory but I like to use them.
EDIT 4: Final Working attempt
The Sandy G's answer below can be use in a Pic and so in a decoration:
\documentclass[tikz]{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}
\newcommand{\hsp}{.5}
\tikzset{symbols/.pic={%
\foreach \s[count=\n from 0] in {a,b,c,f}{%
\pgfmathsetmacro{\myangle}{360rnd}%
\node[anchor=base, inner sep=0pt, outer sep=0pt, rotate=\myangle] at (\hsp\n,0){\s};%
}},%
inlinesymbols/.style={%
decoration={%
markings,%
mark =%
between positions 0 and 1 step 30mm % adjust step size here
with {\pic[red] {symbols};}%
},%
postaction={decorate}%
},%
}%
\begin{document}
\begin{tikzpicture}%[baseline]
\pic[red] {symbols};%
\path[inlinesymbols] (0,-1) -- (4,-1);%
\end{tikzpicture}
\end{document}
This permits to repeat the pattern and also - as Sandy G's method does - to individually set property to one symbol (as for the rotate angle in the above exemple) and globally (as for the red color in e.g.).
EDIT 3: First attempt
I tried something using listoftitems package in order to slipt the comma separated list and loop under the list elements (compared to the previous M(Non)WE above, the new lines of code are encapsulated between the tags: % < Begin NEW > and % < End NEW >).
\documentclass[tikz]{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.markings,positioning}
\usepackage{listofitems}
\def\mysymbollist{a,b,+,9,3}
\tikzset{%
% < Begin NEW >
\setsepchar{,}%
\readlist\mylist\mysymbollist
\foreachitem\x\in\mylist{%
\def\mymacroname{symbols\xcnt}%
\mymacroname/.pic={%
\node{\x};%
},}%
% < End NEW >
inlinesymbols/.style={%
decoration={%
markings,%
mark =%
between positions 0 and 1 step 20mm % adjust step size here
with {% < Begin NEW >
{\foreachitem\x\in\mylist{%
\def\mypicname{symbols\xcnt}%
\pgfmathsetmacro{\myangle}{360*rnd}%
\pic[rotate=\myangle] {\mypicname};}%
}%
% < End NEW >
}%
},%
postaction={decorate}%
},%
}%
\begin{document}
\begin{tikzpicture}
\path[inlinesymbols] (0,0) -- (2,0);%
\end{tikzpicture}
\end{document}
But I got an error :
Incomplete \iffalse; all text was ignored after line 32.
Also the space between two symbols print is not controlled.
Any idea to fix the error and control space between symbols print?
M(Non)WE inspirational sources:
- (1) Tikz inline decoration: pschulz's answer
- (2) Pic with rotate angle: Christoph Frings




PicandDecoration(see my question EDIT 4). Thanks a lot ! – zetyty Mar 19 '22 at 11:58[count=\n]by[count=\n from 0]permits to remove the first horizontal space to the left of the first symbola– zetyty Mar 24 '22 at 09:23