4

I'd like to vertically center a custom column separator in tabular. I have tried

 \begin{tabular}{c @{ $\vcenter{\rightarrow}$ } c @{ $\vcenter{\rightarrow}$ } c}...\end{tabular}

to no avail. Other searches have led to answers directed how to vertically center content within columns but not the actual column separator itself. My minimal working example produces this:

minimal working example visual

whereas I would like (approximately) this:

enter image description here

As always, if you are aware of a solution that does not use tabular or is quite different from my implementation, that is welcomed. Perhaps I should just use no column separators and simply vertically center all the columns.

Here is my minimal working example:

\documentclass[letterpaper]{article}
\usepackage{tikz}
\usepackage[letterpaper, top=2.54cm, bottom=2.54cm, left=2.54cm, right=2.54cm]{geometry}

\begin{document}

\begin{tabular}{c @{ $\rightarrow$ } c @{ $\rightarrow$ } c}

\begin{tikzpicture}[level/.style={level distance=8mm,sibling distance=25mm/#1}]
\node [circle,draw]{17} 
child {node [circle,draw] {9}
    child {node [circle,draw] {7}
        child {node [circle,draw] {3}}
        child {node [circle,draw] {4}}
        }
    child {node [circle,draw] {7}
        child {node [circle,draw] {13}}
        }
    }
child {node [circle,draw] {12}
    child {node [circle,draw] {9}}
    child {node [circle,draw] {5}}
    };
\end{tikzpicture} & 

\begin{tikzpicture}[level/.style={level distance=8mm,sibling distance=25mm/#1}]
\node [circle,draw]{17} 
child {node [circle,draw] {9}
    child {node [circle,draw] {7}
        child {node [circle,draw] {3}}
        child {node [circle,draw] {4}}
        }
    child {node [circle,draw] {13}
        child {node [circle,draw] {7}}
        }
    }
child {node [circle,draw] {12}
    child {node [circle,draw] {9}}
    child {node [circle,draw] {5}}
    };
\end{tikzpicture} &

\begin{tikzpicture}[level/.style={level distance=8mm,sibling distance=25mm/#1}]
\node [circle,draw]{17} 
child {node [circle,draw] {13}
    child {node [circle,draw] {7}
        child {node [circle,draw] {3}}
        child {node [circle,draw] {4}}
        }
    child {node [circle,draw] {9}
        child {node [circle,draw] {7}}
        }
    }
child {node [circle,draw] {12}
    child {node [circle,draw] {9}}
    child {node [circle,draw] {5}}
    };
\end{tikzpicture} \\

[17,9,12,7,7,9,5,3,4,13] & [17,9,12,7,13,9,5,3,4,7] & [17,13,12,7,9,9,5,3,4,7] \\

\end{tabular}

\end{document}

1 Answer 1

5

Add baseline={(current bounding box.center)} as the option to all tikzpictures

\begin{tikzpicture}[baseline={(current bounding box.center)},level...

Code:

\documentclass[letterpaper]{article}
\usepackage{tikz}
\usepackage[letterpaper, top=2.54cm, bottom=2.54cm, left=2.54cm, right=2.54cm]{geometry}

\begin{document}

\begin{tabular}{c @{ $\rightarrow$ } c @{ $\rightarrow$ } c}

\begin{tikzpicture}[baseline={(current bounding box.center)},level/.style={level distance=8mm,sibling distance=25mm/#1}]
\node [circle,draw]{17}
child {node [circle,draw] {9}
    child {node [circle,draw] {7}
        child {node [circle,draw] {3}}
        child {node [circle,draw] {4}}
        }
    child {node [circle,draw] {7}
        child {node [circle,draw] {13}}
        }
    }
child {node [circle,draw] {12}
    child {node [circle,draw] {9}}
    child {node [circle,draw] {5}}
    };
\end{tikzpicture} &

\begin{tikzpicture}[baseline={(current bounding box.center)},level/.style={level distance=8mm,sibling distance=25mm/#1}]
\node [circle,draw]{17}
child {node [circle,draw] {9}
    child {node [circle,draw] {7}
        child {node [circle,draw] {3}}
        child {node [circle,draw] {4}}
        }
    child {node [circle,draw] {13}
        child {node [circle,draw] {7}}
        }
    }
child {node [circle,draw] {12}
    child {node [circle,draw] {9}}
    child {node [circle,draw] {5}}
    };
\end{tikzpicture} &

\begin{tikzpicture}[baseline={(current bounding box.center)},level/.style={level distance=8mm,sibling distance=25mm/#1}]
\node [circle,draw]{17}
child {node [circle,draw] {13}
    child {node [circle,draw] {7}
        child {node [circle,draw] {3}}
        child {node [circle,draw] {4}}
        }
    child {node [circle,draw] {9}
        child {node [circle,draw] {7}}
        }
    }
child {node [circle,draw] {12}
    child {node [circle,draw] {9}}
    child {node [circle,draw] {5}}
    };
\end{tikzpicture} \\

[17,9,12,7,7,9,5,3,4,13] & [17,9,12,7,13,9,5,3,4,7] & [17,13,12,7,9,9,5,3,4,7] \\

\end{tabular}

\end{document}

enter image description here

1
  • Thanks a ton for the quick response. That was exactly what I was looking for.
    – thejmazz
    Jan 19, 2015 at 3:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .