0

enter image description here

I reproduced the table in latex with the code above but I do not know how convert the line into an arrow

\documentclass[12pt]{article}  
\usepackage{tikz}  

\begin{document}  

$\begin{pgfpicture}{0.0cm}{0.0cm}{8.0cm}{8.0cm}
    \pgfsetlinewidth{0.5pt}
    % Row 1  
    \pgfnoderect{A1}[stroke]{\pgfxy(1,4)}{\pgfxy(2,2)}  
    \pgfputat{\pgfxy(0.5,4.5)}{\pgfbox[center,center]{$$}}  
    \pgfputat{\pgfxy(1.5,4.5)}{\pgfbox[center,center]{$6$}}  
    \pgfputat{\pgfxy(0.5,3.5)}{\pgfbox[center,center]{$$}}    
    \pgfputat{\pgfxy(1.5,3.5)}{\pgfbox[center,center]{$$}}    
    \pgfnoderect{A2}[stroke]{\pgfxy(3,4)}{\pgfxy(2,2)}    
    \pgfputat{\pgfxy(2.5,4.5)}{\pgfbox[center,center]{$$}}    
    \pgfputat{\pgfxy(3.5,4.5)}{\pgfbox[center,center]{$10$}}    
    \pgfputat{\pgfxy(2.5,3.5)}{\pgfbox[center,center]{$$}}  
    \pgfputat{\pgfxy(3.5,3.5)}{\pgfbox[center,center]{$$}}  
    \pgfnoderect{B1}[stroke]{\pgfxy(1.5,4.5)}{\pgfxy(1,1)}  
    \pgfnoderect{B2}[stroke]{\pgfxy(3.5,4.5)}{\pgfxy(1,1)}  
    % Row 2  
    \pgfnoderect{A3}[stroke]{\pgfxy(1,6)}{\pgfxy(2,2)}  
    \pgfputat{\pgfxy(0.5,6.5)}{\pgfbox[center,center]{$$}}  
    \pgfputat{\pgfxy(1.5,6.5)}{\pgfbox[center,center]{$5$}}  
    \pgfputat{\pgfxy(0.5,5.5)}{\pgfbox[center,center]{$$}}  
    \pgfputat{\pgfxy(1.5,5.5)}{\pgfbox[center,center]{$$}}  
    \pgfnoderect{A4}[stroke]{\pgfxy(3,6)}{\pgfxy(2,2)}  
    \pgfputat{\pgfxy(2.5,6.5)}{\pgfbox[center,center]{$$}}  
    \pgfputat{\pgfxy(3.5,6.5)}{\pgfbox[center,center]{$9$}}  
    \pgfputat{\pgfxy(2.5,5.5)}{\pgfbox[center,center]{$$}}  
    \pgfputat{\pgfxy(3.5,5.5)}{\pgfbox[center,center]{$$}}  
    \pgfnoderect{B3}[stroke]{\pgfxy(1.5,6.5)}{\pgfxy(1,1)}  
    \pgfnoderect{B4}[stroke]{\pgfxy(3.5,6.5)}{\pgfxy(1,1)}  
    %%%%%%%%%%%%%%%%%%%%%%%%  
    \pgfputat{\pgfxy(4.5,3.5)}{\pgfbox[center,center]{$32$}}  
    \pgfputat{\pgfxy(4.5,5.5)}{\pgfbox[center,center]{$28$}}  
    \pgfputat{\pgfxy(3.0,7.5)}{\pgfbox[center,center]{$v_{2}=2$}}  
    \pgfputat{\pgfxy(1.0,7.5)}{\pgfbox[center,center]{$v_{1}=4$}}  
    \pgfputat{\pgfxy(-1.0,3.5)}{\pgfbox[center,center]{$u_{2}=-2$}}  
    \pgfputat{\pgfxy(-1.0,5.5)}{\pgfbox[center,center]{$u_{1}=-3$}}  
    \pgfputat{\pgfxy(0.5,2.5)}{\pgfbox[center,center]{$48$}}  
    \pgfputat{\pgfxy(2.5,2.5)}{\pgfbox[center,center]{$29$}}  
    %%%%%%%%%%%%%%%%%%%%%%%%   
    \pgfsetendarrow{\pgfarrowsingle}  
    \pgfxycurve(4.75,4.25)(4.75,4.25)(3.75,3.5)(3.75,3.5)  
\end{pgfpicture}$  

\end{document}  
6
  • 1
    It looks like you've got two separate accounts, which means you cannot edit your original post or leave comments. The Stack Exchange staff can merge them together for you. Jul 31, 2016 at 10:34
  • Can you explain, what means added code in your question?
    – Zarko
    Jul 31, 2016 at 12:26
  • @Zarko See the revision history message. EMGA: I added your edit message to the post. Was the code generated by jpgfdraw or something? Jul 31, 2016 at 12:45
  • @TorbjørnT., there seems to be duplication of this question, one of them I edit before. I haven't any idea how this code is generated. Also its purpose is not clear to me.
    – Zarko
    Jul 31, 2016 at 13:15
  • @Zarko The purpose of the code? It generates a diagram much like the one in the image, just try and you'll see. Jul 31, 2016 at 13:26

2 Answers 2

8

As image is simple:

enter image description here

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{positioning}

\begin{document}
\begin{tikzpicture}[node distance = 0mm,
box/.style = {rectangle, draw, minimum size=#1, outer sep = 0pt}
                    ]
\node (n11) [box=20mm,label=above:{$v_1=4$},label=left:{$u_1=-3$}] {};
\node (n12) [box=20mm,label=above:{$v_2=2$},label=right:28,right=of n11] {};
\node (n21) [box=20mm,label=left:{$u_2=-2$},label=below:48,below=of n11] {};
\node (n22) [box=20mm,label=right:32,label=below:29,right=of n21] {};
%
\node (n11a) [box=10mm,below left=of n11.north east] {5};
\node (n12a) [box=10mm,below left=of n12.north east] {9};
\node (n21a) [box=10mm,below left=of n21.north east] {6};
\node (n2a2) [box=10mm,below left=of n22.north east] {10};
    \end{tikzpicture}
\end{document}

Addendum: Let assume, that slanted line at number 32 had to be arrows:

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{positioning}

\begin{document}
\begin{tikzpicture}[node distance = 0mm,
box/.style = {rectangle, draw, minimum size=#1, outer sep = 0pt}
                    ]
\node (n11) [box=20mm,
             label=195:{$u_1=-3$},% on the left side
             label=above:{$v_1=4$}] {};
\node (n12) [box=20mm,
             label=above:{$v_2=2$},
             label=-15:28,% on the right side
             right=of n11] {};
\node (n21) [box=20mm,
             label=195:{$u_2=-2$},% on the left side
             label=below:48,
             below=of n11] {};
\node (n22) [box=20mm,
            label=-15:32,% on the right side
            label=below:29,
            right=of n21] {};
    %
\node (n11a) [box=10mm,below left=of n11.north east] {5};
\node (n12a) [box=10mm,below left=of n12.north east] {9};
\node (n21a) [box=10mm,below left=of n21.north east] {6};
\node (n2a2) [box=10mm,below left=of n22.north east] {10};
% added arrows
\draw[->] ([xshift=-3mm,yshift=5mm] n22.south east) -- + (45:9mm);
    \end{tikzpicture}
\end{document}

in above code also labels are moved to position as it shown in image in question. Result is:

enter image description here

4

As an array in a math environment you can use \multicolumn to span several columns. There is a package multirow that can be used similarly to center over several rows as in Zarko's answer, but this is not how it is specified in the question figure.

\documentclass{article}
\begin{document}
\begin{displaymath}
  \begin{array}{r|p{1.3em}|p{1.3em}|p{1.3em}|p{1.3em}|l}
    \multicolumn{1}{c}{} & \multicolumn{2}{c}{v_1=4} & \multicolumn{2}{c}{v_2=2}\\\cline{2-5}
    & & 5 & & 9 & \\\cline{3-3}\cline{5-5}
    u_1=-3 & \multicolumn{2}{c|}{} & \multicolumn{2}{c|}{} & 28 \\\cline{2-5}
    & & 6 & & 10 & \\\cline{3-3}\cline{5-5}
    u_2=-2 & \multicolumn{2}{c|}{} & \multicolumn{2}{c|}{} & 32 \\\cline{2-5}
    \multicolumn{1}{c}{} & \multicolumn{2}{c}{48} & \multicolumn{2}{c}{29}
  \end{array}
\end{displaymath}
\end{document}

enter image description here

You must log in to answer this question.

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