在马丁·海尔的规律结构简介',第22页出现以下内容:
关于如何在 LaTex 中绘制这些树状符号,有什么建议吗?
答案1
以下是绘制此类树的灵活方法。要更改树的大小,请更改长度\RSu
;初始值为\setlength\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}}
\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}
答案2
我认为那里没有适合这个符号的包。
如果我要画这些图形符号,我可能会tikz
尝试一下。
编辑(添加示例):
\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}