-1

Modi Table

I got the assignment from my lecturer yesterday, to convert this picture/MODI table into LaTeX file. But, i have no idea to start it, because all this time I just understand how to convert MS Word file to a simply latex file and it's not as extreme as this time LOL, so is there a solution to solve this problem?

Thanks for your help! :)

chrisma
  • 1,239
  • I recommend TikZ. There is a good manual on https://www.ctan.org/pkg/pgf. You might want to have a look on http://tug.org/begin.html or https://tex.stackexchange.com/questions/11/what-are-good-learning-resources-for-a-latex-beginner. – CampanIgnis Aug 01 '18 at 11:07

1 Answers1

5

This is a very simple example (here is matrix, loaded via \usetikzlibrary{matrix}, a better choice, but as I said, I want to keep things on a “low-level“). If anyone has a better solution, just edit my answer.

P.S.: I didn't put in the “70“ in the last cell since I don't know for what it stands (it looks like there is something missing in the picture).

\documentclass[border=5pt,tikz]{standalone}
\usepackage{mathptm}
\tikzstyle{io} = [fill=black,radius=3pt]
\begin{document}
    \begin{tikzpicture}[every node/.style={font=\large}]
        \draw[step=2cm] (0,0) grid (8,6);
            \draw[io] (1,1) circle node[below left=4,yshift=-3] {$x_{31}$};
                \node[above left=5,yshift=3] at (1,1) {\small $\theta$};
            \draw[io] (1,5) circle node[above=8] {$30-\theta$};
            \draw[io] (3,5) circle node[above=8] {$20+\theta$};
            \draw[io] (3,3) circle node[below=8] {$20-\theta$};
            \draw[io] (5,3) circle node[above=8] {$30+\theta$};
            \draw[io] (5,1) circle node[below=8] {$30-\theta$};
        \draw[densely dashed] (1,1) -- (1,5) -- (3,5) -- (3,3) -- (5,3) -- (5,1) -- cycle;
    \end{tikzpicture}
\end{document}

The result:

A screenshot


Better solution: An arguably somewhat more flexible code.

\documentclass[border=3.14mm,tikz,x11names,dvipsnames,svgnames]{standalone}
\usetikzlibrary{matrix}
\begin{document}
\begin{tikzpicture}[block/.style ={rectangle, 
draw, fill=white,minimum width=20mm}]

\matrix (mat) [matrix of nodes,nodes={block},nodes in empty cells,
column sep=-\pgflinewidth,row sep=-\pgflinewidth,
row 1/.append style={minimum height=14mm},
row 2/.append style={minimum height=18mm},
row 3/.append style={minimum height=18mm}
]
{
 & & &\\
 & & &\\
 & & &\\
};
\node[circle,fill,label=above:$30-\theta$] at ([yshift=-2mm]mat-1-1.center) (c1) {};
\node[circle,fill,label=above:$20+\theta$] at ([yshift=-2mm]mat-1-2.center) (c2) {};
\node[circle,fill,label=below:$20-\theta$] at (mat-2-2.center) (c3) {};
\node[circle,fill,label=above:$30+\theta$] at (mat-2-3.center) (c4) {};
\node[circle,fill,label=below:$30+\theta$] at (mat-3-3.center) (c5) {};
\node[circle,fill,label=below left:$x_{31}$,label=above left:$\theta$] at (mat-3-1.center) (c6) {};
\foreach \X [evaluate=\X as \Y using {int(1+mod(\X,6))}] in {1,...,6}
{\draw[densely dotted] (c\X) -- (c\Y);}
\end{tikzpicture}
\end{document}

enter image description here

current_user
  • 5,235