3

I tried the basic approach for this table in latex, but I don't like the result, because I don't know how I can avoid every line or border with array*. I just wondering if you know a better way to plot this table, may be with colors for those shadow parts. My worst problem is that in every cell, I have two rows, the next problems are the headers (two first rows and two columns)

enter image description here

My code:

\begin{center}
\begin{tabular}{|l|l|l|l|l|l|l|l|l|l|l|l} \hline
 & &0&1&2&3&4&5&6&7&8 \\ \hline
 & & &1&0&0&1&0&1&0&1 \\ \hline
0& &0&0&0&0&0&0&0&0&0 \\ \hline
1&0&0&0 Sup&1 Diag&1 Diag&1 Izq&1 Diag&1 Izq&1 Diag&1 Izq \\ \hline
2&1&0&1 Diag&1 Sup&1 Sup&2 Diag&2 Izq&2 Diag&2 Izq&2 Diag \\ \hline
3&0&0&1 Sup&2 Diag&2 Diag&2 Sup&3 Diag&3 Izq&3 Diag&3 Izq \\ \hline
4&1&0&1 Diag&2 Sup&2 Sup&3 Diag&3 Sup&4 Diag&4 Izq&4 Diag \\ \hline
5&1&0&1 Diag&2 Sup&2 Sup&3 Diag&3 Sup&4 Diag&4 Sup&5 Diag \\ \hline
6&0&0&1 Sup&2 Diag&3 Diag&3 Sup&4 Diag&4 Sup&5 Diag&5 Sup \\ \hline
7&1&0&1 Diag&2 Sup&3 Sup&4 Diag&4 Sup&5 Diag&5 Sup&6 Diag \\ \hline
8&1&0&1 Diag&2 Sup&3 Sup&4 Diag&4 Sup&5 Diag&5 Sup&6 Diag \\ \hline
9&0&0&1 Sup&2 Diag&3 Diag&4 Sup&5 Diag&5 Sup&6 Diag&6 Sup \\ \hline
\end{tabular}
\end{center}

enter image description here

How can I do somehting like this:

enter image description here

Thanks in advance. Btw, it is a table of LCS for the dynamic programing technique.

  • 1
    Would it be possible to show us what you tried in the form of an MWE? – Au101 Nov 17 '15 at 4:49
  • 1
    Yes, sure. Check the update. – jonaprieto Nov 17 '15 at 5:30
1

according to chapter "5.3 Aligning the Nodes Using Matrices" in the pgfmanual I would try the TikZ matrices to reproduce something like this:

\documentclass{standalone}
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
\usepackage{tikz}
\usetikzlibrary{positioning,shapes,shadows,arrows,matrix}

\begin{document}
    \begin{tikzpicture}
        \tikzstyle{minwidth} = [minimum width=8pt,minimum height=13pt]
        \tikzstyle{g1}=[minwidth,node distance=35pt,font=\footnotesize,text=green!80!black]
        \tikzstyle{g1c}=[g1,circle,draw=red]
        \tikzstyle{m1c}=[matrix of nodes,nodes={rectangle,draw,font=\tiny,minimum width=8pt,minimum height=12pt,text=blue!60!black}]

        \matrix [m1c] (m1)
        {
            0 & 0 & 0 & 0 \\
            0 & |(22) [draw,fill=yellow]| 0 & 0 & 0 \\
            0 & |(23) [draw,fill=yellow]| 1 & |(33) [draw,fill=yellow]| 1 & 1 \\
            0 & 1 & 1 & |(44) [draw,fill=yellow]|  2 \\
        };
        \draw[thick,->] (33.east) -- (23.west);
        \matrix [g1,draw=none, column sep=0cm,above of=m1] (m2)
        {
            \node {$y_j$}; & \node{B};\draw[red] (0,0) circle [radius=5pt]; & \node {D};  & \node {c};\draw[red] (0,0) circle [radius=5pt];\\
        };
        \matrix [draw=none, node distance=10pt,above of=m2,xshift=-8pt] (m5)
        {
            \node {j}; & \node{0}; & \node {1}; & \node{2}; & \node {3};\\
        };

        \matrix [g1,draw=none,, column sep=0cm,left of=m1] (m3)
        {
            \node {$x_i$}; \\  \node{A}; \\  \node {B};\draw[red] (0,0) circle [radius=5pt]; \\ \node {c};\draw[red] (0,0) circle [radius=5pt];  \\
        };
        \matrix [draw=none, node distance=10pt,left of=m3,yshift=8pt] (m4)
        {
            \node {i}; \\ \node {0}; \\  \node{1}; \\  \node {2}; \\ \node {3}; \\
        };
    \end{tikzpicture}
\end{document}

enter image description here

  • Thank you it was a good approach. Although the arrow between the cells looks like a little bad. Anyway Good! – jonaprieto May 24 '18 at 15:02

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.