Math & Science ⇒ Diagonal Arrows in a Matrix
Diagonal Arrows in a Matrix
I don't know how to name it but wonder if the following can be specified by latex?
Thanks for your advise
Last edited by elim on Fri May 18, 2012 5:53 pm, edited 1 time in total.
NEW: TikZ book now 40% off at Amazon.com for a short time.

Diagonal Arrows in a Matrix
You can use tikz (part of the pgf package) for that kind of thing.
Regards
Nicola Talbot
Code: Select all
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\matrix (M)
{
\node (x11) {$x_{11}$}; & \node (x12) {$x_{12}$};
& \node (x13) {$x_{13}$}; & \node (x14) {$x_{14}$};
& \node {\ldots};\\
\node (x21) {$x_{21}$}; & \node {$x_{22}$}; & \node {$x_{23}$};
& \node {$x_{24}$}; & \node {\ldots};\\
\node (x31) {$x_{31}$}; & \node {$x_{32}$}; & \node {$x_{33}$};
& \node {$x_{34}$}; & \node {\ldots};\\
\node (x41) {$x_{41}$}; & \node {$x_{42}$}; & \node {$x_{43}$};
& \node {$x_{44}$}; & \node {\ldots};\\
\node {\ldots}; & \node {\ldots}; & \node {\ldots};
& \node {\ldots}; & \node {\ldots};\\
};
\draw[->] (x11.south west) -- (x11.north east);
\draw[->] (x21.south west) -- (x12.north east);
\draw[->] (x31.south west) -- (x13.north east);
\draw[->] (x41.south west) -- (x14.north east);
\end{tikzpicture}
\end{document}
Nicola Talbot
LaTeX Resources: http://www.dickimaw-books.com/latexresources.html
Creating a Minimal Example: http://www.dickimaw-books.com/latex/minexample/
Creating a Minimal Example: http://www.dickimaw-books.com/latex/minexample/
- Stefan Kottwitz
- Site Admin
- Posts: 10348
- Joined: Mon Mar 10, 2008 9:44 pm
Diagonal Arrows in a Matrix
Hi Elim!
Nicola already gave very good advice. Just a small addition, the code would be shorter and more readable if we would use the TikZ matrix library. Here's the code example of Nicola, using it:
And the output:
Stefan
Nicola already gave very good advice. Just a small addition, the code would be shorter and more readable if we would use the TikZ matrix library. Here's the code example of Nicola, using it:
Code: Select all
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
\begin{tikzpicture}
\matrix (m) [matrix of math nodes]
{
x_{11} & x_{12} & x_{13} & x_{14} & \ldots \\
x_{21} & x_{22} & x_{23} & x_{24} & \ldots \\
x_{31} & x_{32} & x_{33} & x_{34} & \ldots \\
x_{41} & x_{42} & x_{43} & x_{44} & \ldots \\
\ldots & \ldots & \ldots & \ldots & \ldots \\
};
\draw[->] (m-1-1.south west) -- (m-1-1.north east);
\draw[->] (m-2-1.south west) -- (m-1-2.north east);
\draw[->] (m-3-1.south west) -- (m-1-3.north east);
\draw[->] (m-4-1.south west) -- (m-1-4.north east);
\end{tikzpicture}
\end{document}
Stefan
LaTeX.org admin
Re: Diagonal Arrows in a Matrix
Thanks a lot nlct and Stefan_K! Very nice solution!