I would like to make a Zwicky Box by using tabular combined with an overlaying tikzpicture. How can I (semi-)automatically align nodes to the vertical and horizontal center of their corresponding cells?

I understand it would probably work with a matrix which is aligned to the top left corner of the tabular and whose row and column seperation somehow relate to the sizes of the cells (which all have fixed width and height).

Example of what a Zwicky Box could look like

Example of how diamond nodes could look like, made in Excel

So my questions are:

  1. how do I align a tikzpicture exactly with the upper left corner of a tabular?
  2. how do I calculate seperation sizes of columns and rows by knowledge of cell width and height of my tabular environment?
  3. how do I tell a node in which cell of a matrix it shall be placed and that it shall be aligned to the cell's v/h center?
  4. should I actually use a tikzpicture overlaying a tabular? Or would it be better to drop the tabular and put everything into the matrix?
  • Could you provide a link to an image of a Zwicky Box? It seems like there's different ways of drawing them. – Jake May 24 '13 at 13:45
  • BTW, what is a Zwicky Box ? – user13907 May 24 '13 at 13:46
  • 1
    A morphological box. Here's a link to a picture: salemmarafi.com/wp-content/uploads/2011/10/the_new_cookie.png – Hendrik Wiese May 24 '13 at 13:51
  • @HendrikWiese That looks like a simple tabular, maybe with tikzmarks to draw the red line. – Qrrbrbirlbel May 24 '13 at 13:52
  • However, in addition, I'd like to have diamond nodes at the corner points of the poly lines (which actually can be more than just one, in different colors, sharing nodes and crossing each other). @Qrrbrbirlbel: Yeah, but I'd like to have the marks/nodes aligned to the cells. They shall move correspondingly when I change the content of a cell. – Hendrik Wiese May 24 '13 at 13:54

I would do it with a simple tabular using a few tikzmark macros.


   \tikz[every Zwicky picture,#1]{%
     \node[every Zwicky node,draw=none,inner sep=+\z@,outer sep=+\z@] {#3};
       \tikzset{every Zwicky node/.append style={name={#2}}}%
     \node[every Zwicky node,overlay] {\phantom{#3}};
  \tikz[remember picture,overlay]
    \draw[every Zwicky connector,/expanded=\tikz@Zwicky@args]
      (\tikz@Zwicky@first) [/expanded={@Zwicky@list/.list={\tikz@Zwicky@list}}] [every Zwicky connect finish/.try];
  @Zwicky@list/.style={insert path={to[every Zwicky connector how/.try] (#1)}},
  every Zwicky picture/.style={
    remember picture,
  every Zwicky node/.style={
    remember picture,
    inner sep=+2pt
  every Zwicky connector/.style={
    ultra thick,
    draw opacity=.5,
    line cap=round,
    line join=round
                &                                       \multicolumn{4}{c}{\bfseries Configurations}                                        \\ \cmidrule{2-5}
    Parameters  &   \bfseries Cookie A    &        \bfseries Cookie B         &      \bfseries Cookie C      &      \bfseries Cookie D      \\ \midrule
    Texture     &         Smooth          &               Soft                &   \markZwicky(1-3){Chunky}   &             Soft             \\
    Consistency & \markZwicky(2-1){Chewy} &               Goowy               &           Crunchy            &            Chewy             \\
    Size        &         Medium          &               Small               &            Large             &    \markZwicky(3-4){Huge}    \\
    Base        &          Plain          &               Plain               & \markZwicky(4-3){Chocholate} &           Oatmeal            \\
    Topping     &          Sugar          &               None                &            Icing             & \markZwicky(5-4){Chocholate} \\
    Stuffing    &       Chocholate        & \markZwicky(6-2){Dates and Harda} &          Macadamia           &          Chocholate          \\ \bottomrule


enter image description here

  • Still trying to wrap my head around this... but it look promising. Is there a way to automatically mark every cell so that I just would have to add \tiksZwicky at the end with the appropriate mark indices? In larger tables it quickly gets a little bit confusing. – Hendrik Wiese May 27 '13 at 11:58

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.