# Drawing tree-like symbols

In Martin Hairer's 'Introduction to Regularity Structures', on page 22, the following appears:

Any suggestions on how I might be able to draw these tree-like symbols in LaTex?

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}}


\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}

• Wow. This should be a package! Apr 15, 2017 at 15:40
• @gernot I was genuinely not expecting such a good answer. Thank you for having put in the effort to write this for me (and, indeed, all of us)! Apr 15, 2017 at 16:02
• @Richard Thanks for your enthusiasm. I'm afraid that at the moment the use cases for such a package are quite limited, For more flexible trees there are already packages. So let's wait for the killer app that will justify such a package ;-) Apr 15, 2017 at 23:10
• @man_in_green_shirt Well, it was a nice question also. And it was fun on a Saturday afternoon. Apr 15, 2017 at 23:11
• Really nice. One day I'll understand the loop trick.... Maybe ;-) Apr 20, 2017 at 21:45

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.

\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}