tree-dvips を置き換えて、表形式の環境でノードを接続する

tree-dvips を置き換えて、表形式の環境でノードを接続する

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 2013 ではなく texlive 2014 を必要とするものはありますか?

答え1

を使用してtcolorbox、接続するパーツの周囲にアンカーとなる非表示のボックス ( southnorthなど) を構築し、手動計算を回避することができます。

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

ここに画像の説明を入力してください

完全を期すために、2 番目の画像に似た別の画像を以下に示します。

\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独自に定義できます。パッケージを使用する必要はありません。\tikzmarknodetcolorbox

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

ここに画像の説明を入力してください

関連情報