0

I'm trying to draw this picture, which is created from MS Excel.

enter image description here

I'm only able to draw a simple rectangle

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

\begin{document}

\begin{tikzpicture}
\draw (0,0) -- (7,0) -- (7,4) -- (0,4) -- (0,0);
\end{tikzpicture}

\end{document}

Could you please elaborate on how to draw such figure? Thank you so much!

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

\begin{document}

\begin{tikzpicture}[yscale=0.7]
\draw (0,0) rectangle (7,3) (3,3) -- (3,0) -- (0,3) 
 (0.2,0.2) node[above right,font=\Huge]{$0$}
foreach \X [count=\Y] in {1,3,7} {(0,3.5-\Y) node[red,left] {$\X$}
 (-0.5+\Y,3) node[red,above] {$\X$}}
foreach \X [count=\Y] in {2,4,5,6} {(2.5+\Y,3) node[above] {$\X$}};
\end{tikzpicture}

\end{document}

enter image description here

As for the code in your comment:

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

\begin{document}

\begin{tikzpicture}[yscale=0.7]     
\draw (0,0) rectangle (6,3) (3,3) -- (3,0) -- (0,3)     
(0.4,0.4) node[above right,font=\Huge]{$\mathbf 0$}     
foreach \X/\Z [count=\Y] in {i_1,\cdots/\vdotswithin{i_1},i_k} {(0,3.5-\Y)
 node[red,left] {$\Z$}  
(-0.5+\Y,3) node[red,above] {$\X$}}     
foreach \X [count=\Y] in
{i_{k+1},\cdots,i_N} {(2.5+\Y,3) node[above] {$\X$}};   
\end{tikzpicture}
\end{document}

enter image description here

| improve this answer | |
  • I've tried to modify your code to include the dots. The horizontal dots is fine, but the vertical dots is not as expected. I guess this is because they are the same. Could you please help me edit this code to have the vertical dots. – LAD Jun 16 at 18:46
  • This is how I modify your code: \begin{tikzpicture}[yscale=0.7] \draw (0,0) rectangle (6,3) (3,3) -- (3,0) -- (0,3) (0.4,0.4) node[above right,font=\Huge]{$\mathbf 0$} foreach \X [count=\Y] in {i_1,\cdots,i_k} {(0,3.5-\Y) node[red,left] {$\X$} (-0.5+\Y,3) node[red,above] {$\X$}} foreach \X [count=\Y] in {i_{k+1},\cdots,i_N} {(2.5+\Y,3) node[above] {$\X$}}; \end{tikzpicture}. – LAD Jun 16 at 18:46
2

For example, this plain TeX code creates the numbers around the rectangle:

\hbox to150bp{\def\h{\hskip0pt plus2fil}\hfil 1\h 3\h 7\h 2\h 4\h 5\h 6\hfil}
\medskip
\hbox{\llap{\vbox to30bp{\def\h#1{\hbox{#1}}\h1\vfil\h3\vfil\h7}\kern8bp}%
  \pdfliteral{q 1 j 1 J 0 0 m 150 0 l 150 30 l 0 30 l s 60 30 m 60 0 l 0 30 l S Q}}

\bye
| improve this answer | |
2

You can obtain it with a simple tabular and some tools from latex (array,diagbox,multirow):

\documentclass{article}
\usepackage{xcolor}
\usepackage{array, diagbox, multirow}

\begin{document}

{\sffamily\renewcommand{\arraystretch}{1.3}
\begin{tabular}{ >{\color{red}}c|*{3}{>{\color{red}}c}|*{4}{c}|}
\multicolumn{1}{c}{} & 1 & 3 & \multicolumn{1}{c}{\color{red}7} & 2 & 4 & 5 & \multicolumn{1}{c}{6} \\ \cline{2-8}
 1 & \multicolumn{3}{c|}{\multirow{3}{*}{\diagbox[height=3.85pc, width=4.3pc]{\huge 0}{}}}& & & & \\
 3 & & & & & & & \\
 7 & & & & & & & \\[-0.4pt] \cline{2-8}
\end{tabular}}

\end{document} 

enter image description here

| improve this answer | |

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.