14

I would like to just create a grid like this, but without numbers or color, but I'd like to represent an n × n grid abstractly with ellipses like this:

enter image description here


Also, I need just a simple—singular—grid like that of the top left grid in the image above.


I know need a red line (y=x) from the lower left corner to the upper right corner.

5
  • 1
    Welcome to TeX.SX! I added the picture you linked to the question. Later, with more reputation points earned, you will be able to do it yourself. Happy TeXing! :)
    – Count Zero
    Jul 25, 2013 at 20:35
  • Would you rather do this as a table or as a tikzpicture (since you seem to have included both tags)?
    – MaxAxeHax
    Jul 25, 2013 at 20:45
  • I included both tags so that the experienced answerer could choose between the easier of the two, but I would like to get a handle on tikz, so perhaps tikz is my answer. Jul 25, 2013 at 20:49
  • It could be done in a tabular, but the fact that the rules aren't continuous would cause for some ugliness. It's not that it's hard (once you get to grips with tabulars), it's just ugly. (The tabular solution would potentially be more efficient, but the TikZ solution is prettier by far.) Jul 25, 2013 at 23:06
  • I just know there is a good way to do this with ytableau; I just don't know what it is. The attempt has uncovered several potentially useful features I could add, though.
    – Ryan Reich
    Jul 26, 2013 at 0:17

1 Answer 1

22

A very basic approach using grid:

\documentclass{article}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
\draw (0,0) grid (3,3);
\draw (0,4) grid (3,7);
\draw (4,0) grid (7,3);
\draw (4,4) grid (7,7);
\foreach \i/\valor in {1/1,2/2,3/3,5/n-2,6/n-1,7/n}
  {
    \node[anchor=south] at (\i-0.5,7) {$\valor$};
    \node[anchor=east] at (0,-\i+7.5) {$\valor$};
}
\node at (3.5,1.5) {$\cdots$};
\node at (3.5,5.5) {$\cdots$};
\node at (1.5,3.5) {$\vdots$};
\node at (5.5,3.5) {$\vdots$};
\node at (3.5,3.5) {$\ddots$};
\end{tikzpicture}

\end{document}

enter image description here

With the new requirement of the edited question:

\documentclass{article}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
\draw (0,0) grid (3,3);
\draw (0,4) grid (3,7);
\draw (4,0) grid (7,3);
\draw (4,4) grid (7,7);
\foreach \i/\valor in {1/1,2/2,3/3,5/n-2,6/n-1,7/n}
  {
    \node[anchor=south] at (\i-0.5,7) {$\valor$};
    \node[anchor=east] at (0,-\i+7.5) {$\valor$};
}
\node at (3.5,1.5) {$\cdots$};
\node at (3.5,5.5) {$\cdots$};
\node at (1.5,3.5) {$\vdots$};
\node at (5.5,3.5) {$\vdots$};
\node at (3.5,3.5) {$\ddots$};
\draw[red,ultra thick] (0,0) -- (7,7);
\end{tikzpicture}

\end{document}

enter image description here

5
  • OMG... You are amazing. Thank you! :-) Jul 26, 2013 at 5:56
  • What if I want to put a giant slash from the lower left corner to the upper right corner in red? Jul 27, 2013 at 1:26
  • @LoieBenedicte just before \end{tikzpicture}, you can add \draw[red] (0,0) -- (7,7); Jul 27, 2013 at 1:30
  • Hmmm... How do you get a bold red? Jul 27, 2013 at 2:38
  • @LoieBenedicte do you mean to increase the line width? If so, \draw[red, ultra thick] (0,0) -- (7,7); or \draw[red,line width=4pt] (0,0) -- (7,7); (change 4pt to the desired value). Jul 27, 2013 at 2:40

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.