Math & Sciencecrossed lines in a matrix

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
fesghelbahal
Posts: 3
Joined: Fri Oct 22, 2010 11:07 pm

crossed lines in a matrix

Post by fesghelbahal »

Hi,

I'm typesetting a document in amsart document class. I want to show the different cases of a matrix with term rank 2 by drawing two lines in a matrix. How can I make a vertical line and a horizontal line to cross each other, something like:
Image

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

crossed lines in a matrix

Post by gmedina »

Hi,

the following code could give you some ideas:

Code: Select all

\documentclass{amsart}
\usepackage{tikz}
\usetikzlibrary{matrix}

\begin{document}

\begin{tikzpicture}\small
\matrix (2rank) [matrix of math nodes, left delimiter = {[}, right delimiter = {]}]
  {%
  \phantom{\cdot} & \phantom{\cdot} & \phantom{\cdot} & \phantom{\cdot} \\
  \phantom{\cdot} & \phantom{\cdot} & \phantom{\cdot} & \phantom{\cdot} \\
  \phantom{\cdot} & \phantom{\cdot} & \phantom{\cdot} & \phantom{\cdot} \\
  \phantom{\cdot} & \phantom{\cdot} & \phantom{\cdot} & \phantom{\cdot} \\
  };
  \draw[help lines] (2rank-1-1.north) -- (2rank-4-1.south);
  \draw[help lines] (2rank-1-1.west) -- (2rank-1-4.east);
\end{tikzpicture}

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
fesghelbahal
Posts: 3
Joined: Fri Oct 22, 2010 11:07 pm

Re: crossed lines in a matrix

Post by fesghelbahal »

Wow :shock: , thanks. This is really helpful. :idea:
fesghelbahal
Posts: 3
Joined: Fri Oct 22, 2010 11:07 pm

crossed lines in a matrix

Post by fesghelbahal »

And one more question, I used exactly the same code that you've written here, and it works fine. Now I want to give the matrix a name, say A, and I wrote

Code: Select all

$A=$
\begin{tikzpicture}\small
\matrix (2rank) [matrix of math nodes, left delimiter = {[}, right delimiter = {]}]
  {%
  \phantom{\cdot} & \phantom{\cdot} & \phantom{\cdot} & \phantom{\cdot} \\
  \phantom{\cdot} & \phantom{\cdot} & \phantom{\cdot} & \phantom{\cdot} \\
  \phantom{\cdot} & \phantom{\cdot} & \phantom{\cdot} & \phantom{\cdot} \\
  \phantom{\cdot} & \phantom{\cdot} & \phantom{\cdot} & \phantom{\cdot} \\
  };
  \draw[help lines] (2rank-1-1.north) -- (2rank-4-1.south);
  \draw[help lines] (2rank-1-1.west) -- (2rank-1-4.east);
\end{tikzpicture}
But "A=" appears on the lower left corner of the matrix, how can I bring matrix down, such that it shows it just in front of "A="?
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

crossed lines in a matrix

Post by gmedina »

You can use a node:

Code: Select all

\documentclass{amsart}
\usepackage{tikz}
\usetikzlibrary{matrix}

\begin{document}

\begin{tikzpicture}\small
\matrix (2rank) [matrix of math nodes, left delimiter = {[}, right delimiter = {]}]
  {%
  \phantom{\cdot} & \phantom{\cdot} & \phantom{\cdot} & \phantom{\cdot} \\
  \phantom{\cdot} & \phantom{\cdot} & \phantom{\cdot} & \phantom{\cdot} \\
  \phantom{\cdot} & \phantom{\cdot} & \phantom{\cdot} & \phantom{\cdot} \\
  \phantom{\cdot} & \phantom{\cdot} & \phantom{\cdot} & \phantom{\cdot} \\
  };
  \draw[help lines] (2rank-1-1.north) -- (2rank-4-1.south);
  \draw[help lines] (2rank-1-1.west) -- (2rank-1-4.east);
  \node at (-1.3,0) {$A=$};
\end{tikzpicture}

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
Post Reply