答案1
改编自我对“绘制树状符号”的回答. 修改长度\RSu
来改变符号的大小。
\documentclass{article}
\usepackage{tikz}
\makeatletter
\newcommand\RSloop{\@ifnextchar\bgroup\RSloopa\RSloopb}
\makeatother
\newcommand\RSloopa[1]{\bgroup\RSloop#1\relax\egroup\RSloop}
\newcommand\RSloopb[1]{%
\ifx\relax#1%
\else
\ifcsname RS:#1\endcsname
\csname RS:#1\endcsname
\else
\GenericError{(RS)}{RS Error: operator #1 undefined}{}{}%
\fi
\expandafter\RSloop
\fi
}
\newcommand\X{0}
\newcommand\RS[1]{%
\begin{tikzpicture}
[every node/.style=
{circle,draw,fill,minimum size=1.5pt,inner sep=0pt,outer sep=0pt},
line cap=round
]
\node[label=below:\tiny$2$] (0) {};
\node[label=below:\tiny$1$,xshift=-\RSu] (l) {};
\node[label=below:\tiny$3$,xshift=\RSu] (r) {};
\node[yshift=\RSu] (u) {};
\RSloop{#1}\relax
\end{tikzpicture}
}
\newcommand\RSdef[1]{\expandafter\def\csname RS:#1\endcsname}
\newlength\RSu
\RSu=1ex
\RSdef{l}{\draw (l) -- (u);}
\RSdef{|}{\draw (0) -- (u);}
\RSdef{r}{\draw (r) -- (u);}
\RSdef{-}{\draw (l) -- (0);}
\RSdef{+}{\draw (0) -- (r);}
\begin{document}
\section*{The operators}
\begin{tabular}{ll}
\texttt l = \RS l & \texttt r = \RS r \\
\texttt - = \RS - & \texttt + = \RS + \\
\multicolumn{1}{c}{ \texttt | = \RS |}
\end{tabular}
\section*{Examples}
\RS{} \RS{l} \RS{|} \RS{l|} \RS{r} \RS{lr} \RS{|r} \RS{l|r}\\
\RS{-} \RS{l-} \RS{-|} \RS{-r} \RS{lr-} \RS{-|r}\\
\RS{-+} \RS{l-+} \RS{-|+} \RS{-+r} \RS{lr-+}
\end{document}