1

I want to get rid of tree-dvips since it is not compatible with xelatex and ps-tricks since it does not compile efficiently with xelatex. I have the following figures:

enter image description here

enter image description here

They were typeset by using tabular for the arrangement of the nodes. Then I used tree-dvips (and later ps-tricks) to connect the handles (h0, h7, ...) to the term that the handles dominate. The lines start below the handle and end north of the dominated node, in the middle of the dominated node.

Now I have a solution using tikzmark, but the disadvantage seems to be that one has to shift the positions of the marked elements around by hand, that is, the lines do not end north/middle and do not start south/middle.

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

(The shifting is not done properly in my MWE since I think this is not necessary in the real solution). I tried to put a tabular environment into tikzpicture or use \subnode in a tabular environment, but neither of these attempts did work.

Edit: I tried the solution below, but got:

! 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]
 ? 

Is there anything in tcb that requires texlive 2014 rather than 2013?

3
  • Pstricks compiles fine with XeLateX!
    – Bernard
    Dec 17 '14 at 14:05
  • Yes, I know, but terribly slow ... Dec 17 '14 at 14:08
  • It's XeLaTeX that's slow on first run…
    – Bernard
    Dec 17 '14 at 14:10
3

You can use tcolorbox to build invisible boxes around the parts that you want to connect that will provide anchors (like south, north, etc.), in order to avoid manual calculations.

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

enter image description here

Just for the sake of completeness, another one similar to the second picture with:

\draw(h3.south) .. controls +(0,-1) and +(-1,1)..  (h6.north);

enter image description here

Edit: To summarize the discussion in the comments, the following code does not use the empty key (not available in TeX Live 2013) and uses bottom and top to add more space above and below the boxes.

\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}
6
  • Thanks! I somehow got an error when compiling the code. See edit above. Dec 17 '14 at 19:33
  • @StefanMüller You are probably using an outdated version of the tcolorbox package. The above code needs version 3.00 at least. If you can't update your packages I'll offer a workaround (that does not use the empty key).
    – Old Nick
    Dec 17 '14 at 19:46
  • Thanks! I will update the package. I updated to tex live 2014 some time ago, but this broke something so I reverted to 2013. Maybe I should try again, but just updating to tcolorbox 3.0 seems to be sufficient for now. Dec 17 '14 at 19:52
  • Is there a way to increase the distance between the nodes and the lines? I guess the boxes would have to be a bit bigger, 2 or 3 points. I played with the =< and => but this just shortens the lines rather then increasing the distance. Dec 17 '14 at 19:54
  • @StefanMüller sorry, I misread you last comment... if you want bigger boxes add top=<value> and bottom=<value to the mybox code. It will affect all boxes.
    – Old Nick
    Dec 17 '14 at 20:02
3

Instead of using the package tikzmark, you can define your own \tikzmark being a regular node. There's no need to use tcolorbox package.

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

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.