我想使用forest
大号\llbracket
和\rrbracket
围绕它的树(语义解释括号)来创建一棵树。schemabox
看起来很有希望,但似乎不起作用。
我该怎么做呢?
(或者,是否有另一个我可以使用来执行此操作的树包?)
\documentclass[a4paper]{article}
\usepackage{graphicx}
\usepackage{forest}
\begin{document}
% big open double-bracket here
\begin{forest}
[A tree]
\end{forest}
% big close double-bracket here
\end{document}
答案1
\documentclass[a4paper]{article}
\usepackage{graphicx}
\usepackage{forest,stmaryrd}
\begin{document}
$\left\llbracket
\begin{forest}
[A tree]
\end{forest}
\right\rrbracket$
\end{document}
执行此操作的宏,垂直居中:
\newcommand{\brr}[1]{
\left\llbracket\raisebox{-.5\height}{ #1 }
\right\rrbracket}
使用:
\begin{equation}
\brr{\begin{forest}[X]\end{forest}}
\end{equation}
答案2
由于forest
用途,tikz
您可以简单地进行绘图tikz
:
代码:
\documentclass[a4paper]{article}
\usepackage{graphicx}
\usepackage{forest}
\newcommand{\StubSize}{0.5em}%
\newcommand{\BraceForest}[1][]{%
\begin{scope}[overlay]
\coordinate (Left Start) at ($(current bounding box.south west)+(\StubSize,0ex)$);
\coordinate (Left End) at ($(current bounding box.north west)+(\StubSize,0ex)$);
\coordinate (Right Start) at ($(current bounding box.south east)-(\StubSize,0ex)$);
\coordinate (Right End) at ($(current bounding box.north east)-(\StubSize,0ex)$);
\draw [#1] (Left Start)
-- (current bounding box.south west)
-- (current bounding box.north west)
-- (Left End);
\draw [#1] (Right Start)
-- (current bounding box.south east)
-- (current bounding box.north east)
-- (Right End);
\end{scope}
}
\begin{document}
\begin{forest}
[A tree]
\BraceForest[red,ultra thick]%
\end{forest}
\end{document}