Drawing tree-like symbols

Here is a flexible approach to draw such trees. To change the size of the tree, change the length \RSu; the initial value is \setlength\RSu{1ex}. You can easily define more operators by looking at the current definitions:

\RSdef{i}{\draw (\X) -- +(90:\RSu) node{};}
\RSdef{l}{\draw (\X) -- +(135:\RSu) node{};}
\RSdef{r}{\draw (\X) -- +(45:\RSu) node{};}
\RSdef{I}{\draw (\X) -- +(90:\RSu) coordinate(\X I);\edef\X{\X I}}
\RSdef{L}{\draw (\X) -- +(135:\RSu) coordinate(\X L);\edef\X{\X L}}
\RSdef{R}{\draw (\X) -- +(45:\RSu) coordinate(\X R);\edef\X{\X R}}

enter image description here

\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
     ]
   \coordinate(\X) at (0,0);
   \RSloop{#1}\relax
   \end{tikzpicture}
  }
\newcommand\RSdef[1]{\expandafter\def\csname RS:#1\endcsname}
\newlength\RSu
\RSu=1ex
\RSdef{i}{\draw (\X) -- +(90:\RSu) node{};}
\RSdef{l}{\draw (\X) -- +(135:\RSu) node{};}
\RSdef{r}{\draw (\X) -- +(45:\RSu) node{};}
\RSdef{I}{\draw (\X) -- +(90:\RSu) coordinate(\X I);\edef\X{\X I}}
\RSdef{L}{\draw (\X) -- +(135:\RSu) coordinate(\X L);\edef\X{\X L}}
\RSdef{R}{\draw (\X) -- +(45:\RSu) coordinate(\X R);\edef\X{\X R}}
\begin{document}

\section*{The operators}

\begin{tabular}{lll}
\verb"l" & line left and draw node      & \RS{l} \\
\verb"i" & line up and draw node        & \RS{i} \\
\verb"r" & line right and draw node     & \RS{r} \\
\verb"L" & line left and move position  & \RS{L} \\
\verb"I" & line up and move position    & \RS{I} \\
\verb"R" & line right and move position & \RS{R} \\
\verb"{...}" & confine position change &
\end{tabular}

\section*{Examples}

\begin{tabular}{rl}
  \RS{lir}    & \verb"\RS{lir}"    \\
  \RS{lr}     & \verb"\RS{lr}"     \\
  \RS{lrIlir} & \verb"\RS{lrIlir}" \\
  \RS{i}      & \verb"\RS{i}"      \\
  \RS{rIlir}  & \verb"\RS{rIlir}"  \\
  \RS{lrIlr}  & \verb"\RS{lrIlr}"  \\
  \RS{Ilir}   & \verb"\RS{Ilir}"   \\
  \RS{Ilir}   & \verb"\RS{Ilir}"   \\
  \RS{rIlr}   & \verb"\RS{rIlr}"   \\
  \RS{{LL{Lil}{Ii}{Ri}}{RR{Li}{Ii}{Rir}}} &
    \verb"\RS{{LL{Lil}{Ii}{Ri}}{RR{Li}{Ii}{Rir}}}"
\end{tabular}

\end{document}

I don't think there are packages for this symbol out there.

If I'm going to draw these graphical notations, I might give tikz a try.

EDIT(add example):

\documentclass[10pt,openany,landscape]{ctexbook}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{5pt}

\usepackage[hmargin={1cm},vmargin={5.5cm}]{geometry}
\usepackage{tikz}
\usepackage{xcolor}
\usetikzlibrary{arrows,calc,positioning}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{5pt}
\begin{document}

\begin{tikzpicture}
\coordinate (t1_0) at (0, 0);
\coordinate (t1_1) at ($(t1_0) + (130:6mm)$);
\coordinate (t1_2) at ($(t1_0) + (0,6mm)$);
\coordinate (t1_3) at ($(t1_0) + (50:6mm)$);
\draw [thick] (t1_1) to (t1_0) to (t1_3);
\draw [thick] (t1_0) to (t1_2);
\filldraw (t1_1) circle [radius=1mm];
\filldraw (t1_2) circle [radius=1mm];
\filldraw (t1_3) circle [radius=1mm];

\coordinate (t2_0) at (1cm, 0);
\coordinate (t2_1) at ($(t2_0) + (70:6mm)$);
\coordinate (t2_2) at ($(t2_0) + (110:6mm)$);
\draw [thick] (t2_1) to (t2_0) to (t2_2);
\filldraw (t2_1) circle [radius=1mm];
\filldraw (t2_2) circle [radius=1mm];
\end{tikzpicture}

\end{document}

enter image description here

Tags:

Symbols