3

I have an assignment at university and I have to write some documents written by hand into a TeX document. I'm facing a problem with the following table:

Is it possible to achieve a result similar to the picture above using TeX? I'm not asking for a provided working solution, I'm wondering if I should do it with a photo editor or not (and in this case a little hint would be helpful).

Mangusto
  • 133
  • 3

2 Answers2

4

You can try tikz package and put your table (I use the simple tableau package here) inside a node to make drawing easier. Here is my code:

\documentclass[border=2mm]{standalone}
\usepackage{ytableau,tikz,varwidth}
\usetikzlibrary{calc,shapes}
\begin{document}

\ytableausetup{boxsize=2em}
\begin{tikzpicture}[b/.style={rounded corners,fill=blue!50,opacity=0.5,minimum width=1.2em,minimum height=7.5em}]
\node (n) {\begin{varwidth}{5cm}{
\begin{ytableau}
50 & 0 & 150 & 200 \\
50 & 0 & 200 & 100 \\
100 & 0 & 250 & 200 \\
0 & 0 & 0 & 0 \\
\end{ytableau}}\end{varwidth}};

\node [b] at ([xshift=-1em]n) {};
\node [b,rotate=90] at ([yshift=-3em]n) {};

\end{tikzpicture}
\end{document}

The table now looks like this:

enter image description here

AboAmmar
  • 46,352
  • 4
  • 58
  • 127
3

Only with tikz and the fit and matrix libraries. I also used backgrounds library for highlighting in the background (and does not cover the numbers).

\documentclass[border=1mm,tikz]{standalone}
\usetikzlibrary{fit,matrix,backgrounds}
\begin{document}
\begin{tikzpicture}
\matrix[matrix of math nodes,% Not strictly necessary but useful to put math symbols $...$
row sep=-\pgflinewidth,column sep=-\pgflinewidth,% Overlaps borders of the nodes 
nodes={draw,minimum width=2em,minimum height=2em},inner sep=0.5ex] (mymatrix) {
    50  & 0 & 150 & 200 \\
    50  & 0 & 200 & 100 \\
    100 & 0 & 250 & 200 \\
     0  & 0 &  0  &  0  \\
};
\begin{pgfonlayer}{background}
\node[fill=blue!50,opacity=0.5,inner sep=-0.8ex,rounded corners=6pt,fit=(mymatrix-1-2)(mymatrix-4-2)] {};
\node[fill=blue!50,opacity=0.5,inner sep=-1ex,rounded corners=6pt,fit=(mymatrix-4-1)(mymatrix-4-4)] {};
\end{pgfonlayer}
\end{tikzpicture}
\end{document}

enter image description here

skpblack
  • 8,904
  • 3
  • 31
  • 42