
Я хочу избавиться от tree-dvips, так как он несовместим с xelatex, и от ps-tricks, так как он не компилируется эффективно с xelatex. У меня есть следующие цифры:
Они были набраны с помощью tabular
для расположения узлов. Затем я использовал tree-dvips
(и позже ps-tricks
) для соединения ручек (h0, h7, ...) с термином, что ручки доминируют. Линии начинаются под ручкой и заканчиваются к северу от доминируемого узла, в середине доминируемого узла.
Теперь у меня есть решение с использованием tikzmark
, но недостаток, по-видимому, в том, что приходится вручную сдвигать положения отмеченных элементов, то есть линии не заканчиваются на севере/в середине и не начинаются на юге/в середине.
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{tikzmark} % saves positions in tikz pictures, allows to connect arbitrary text
\usetikzlibrary{calc}
\begin{document}
\begin{figure}
\centering
\begin{tabular}{@{}ccc@{}}
& \tikzmark{h0}{h0} & \\[4ex]
\tikzmark{h8}{h8:wieder(\tikzmark{h8h9}{h9})}\\[4ex]
\tikzmark{h1}{h1:every(x, \tikzmark{h1h2}{h2}, \tikzmark{h1h3}{h3})} & & \tikzmark{h6}{h6:CAUSE(max, \tikzmark{h6h7}{h7})}\\[8ex]
\tikzmark{h4}{h4:window(x)} & & \\[6ex]
& \tikzmark{h5}{h5:open(x)}\\
\end{tabular}
\begin{tikzpicture}[overlay,remember picture]
\draw[dashed] ($(pic cs:h0)+(3ex,2.5ex)$) to($(pic cs:h8)+(1ex,2ex)$);
\draw[dashed] ($(pic cs:h0)+(3ex,2.5ex)$) to($(pic cs:h6)+(1ex,2ex)$);
\draw[dashed] ($(pic cs:h8h9)+(3ex,2.5ex)$) to($(pic cs:h1)+(1ex,2ex)$);
\draw[dashed] ($(pic cs:h6h7)+(3ex,2.5ex)$) to($(pic cs:h5)+(1ex,2ex)$);
\draw[dashed] ($(pic cs:h1h2)+(3ex,2.5ex)$) to($(pic cs:h4)+(1ex,2ex)$);
\draw[dashed] ($(pic cs:h1h3)+(3ex,2.5ex)$) to($(pic cs:h5)+(1ex,2ex)$);
\end{tikzpicture}
\end{figure}
\end{document}
(В моем MWE смещение не выполняется должным образом, поскольку я считаю, что в реальном решении это не нужно.) Я пытался поместить табличную среду в tikzpicture или использовать ее \subnode
в табличной среде, но ни одна из этих попыток не сработала.
Редактировать:Я попробовал решение ниже, но получил:
! Package pgfkeys Error: I do not know the key '/tcb/empty' and I am going to i
gnore it. Perhaps you misspelled it.
See the pgfkeys package documentation for explanation.
Type H <return> for immediate help.
...
l.15 & \mybox[h0]{h0}
& \\[4ex]
?
Есть ли в tcb что-нибудь, требующее texlive 2014, а не 2013?
решение1
Вы можете использовать его tcolorbox
для создания невидимых рамок вокруг деталей, которые вы хотите соединить, которые будут служить якорями (например south
, north
, и т. д.), чтобы избежать ручных вычислений.
\documentclass{article}
\usepackage{tcolorbox}
\tcbuselibrary{skins}
\newtcbox{\mybox}[1][]{empty,shrink tight,nobeforeafter,on line,before upper=\vphantom{gM},remember as=#1}
\begin{document}
\begin{figure}
\centering
\begin{tabular}{@{}ccc@{}}
& \mybox[h0]{h0} & \\[4ex]
\mybox[h8]{h8:wieder}\mybox[h9]{(h9)} \\[4ex]
\mybox[h1]{h1:every(x, \mybox[h2]{h2}, \mybox[h3]{h3})} & & \mybox[h6]{h6:CAUSE(max, \mybox[h7]{h7})}\\[8ex]
\mybox[h4]{h4:window(x)} & & \\[6ex]
& \mybox[h5]{h5:open(x)}\\
\end{tabular}
\begin{tikzpicture}[overlay,remember picture,draw=gray,dashed,shorten <=2pt,shorten >=2pt]
\draw(h0.south)--(h8.north);
\draw(h0.south)--(h6.north);
\draw(h9.south)--(h1.north);
\draw(h2.south)--(h4.north);
\draw(h3.south)--(h5.north);
\draw(h7.south)--(h5.north);
\end{tikzpicture}
\end{figure}
\end{document}
Для полноты картины еще одна картинка, похожая на вторую:
\draw(h3.south) .. controls +(0,-1) and +(-1,1).. (h6.north);
Редактировать:Подводя итог обсуждения в комментариях, следующий код не использует клавишу empty
(недоступно в TeX Live 2013), а использует bottom
и top
для добавления большего пространства над и под полями.
\documentclass{article}
\usepackage{tcolorbox}
\tcbuselibrary{skins}
\newtcbox{\mybox}[1][]{enhanced,boxrule=0pt,colframe=white,colback=white,shrink tight,nobeforeafter,on line,before upper=\vphantom{gM},remember as=#1,top=3pt,bottom=3pt}
\begin{document}
\begin{figure}
\centering
\begin{tabular}{@{}ccc@{}}
& \mybox[h0]{h0} & \\[4ex]
\mybox[h8]{h8:wieder}\mybox[h9]{(h9)} \\[4ex]
\mybox[h1]{h1:every(x, \mybox[h2]{h2}, \mybox[h3]{h3})} & & \mybox[h6]{h6:CAUSE(max, \mybox[h7]{h7})}\\[8ex]
\mybox[h4]{h4:window(x)} & & \\[6ex]
& \mybox[h5]{h5:open(x)}\\
\end{tabular}
\begin{tikzpicture}[overlay,remember picture,draw=gray,dashed,shorten <=2pt,shorten >=2pt]
\draw(h0.south)--(h8.north);
\draw(h0.south)--(h6.north);
\draw(h9.south)--(h1.north);
\draw(h2.south)--(h4.north);
\draw(h3.south)--(h5.north);
\draw(h7.south)--(h5.north);
\end{tikzpicture}
\end{figure}
\end{document}
решение2
Вместо использования пакета tikzmark
вы можете определить свой собственный, \tikzmark
являющийся регулярным node
. Нет необходимости использовать tcolorbox
пакет.
\documentclass{article}
\usepackage{tikz}
\newcommand{\tikzmark}[2]%
{\tikz[baseline=(#1.base), remember picture]\node[outer sep=0pt, inner sep=0pt] (#1) {#2};}
\begin{document}
\begin{figure}
\centering
\begin{tabular}{@{}ccc@{}}
& \tikzmark{h0}{h0} & \\[4ex]
\tikzmark{h8}{h8:wieder}\tikzmark{h8h9}{(h9)}\\[4ex]
\tikzmark{h1}{h1:every}(x, \tikzmark{h1h2}{h2}, \tikzmark{h1h3}{h3}) & & \tikzmark{h6}{h6:CAUSE}(max, \tikzmark{h6h7}{h7})\\[8ex]
\tikzmark{h4}{h4:window(x)} & & \\[6ex]
& \tikzmark{h5}{h5:open(x)}\\
\end{tabular}
\begin{tikzpicture}[overlay,remember picture,draw=gray,dashed,shorten <=2pt,shorten >=2pt]
\draw(h0.south)--(h8.north);
\draw(h0.south)--(h6.north);
\draw(h8h9.south)--(h1.north);
\draw(h1h2.south)--(h4.north);
\draw(h1h3.south)--(h5.north);
\draw(h6h7.south)--(h5.north);
\end{tikzpicture}
\end{figure}
\end{document}