Math & Science ⇒ Diagonal Arrows in a Matrix
Diagonal Arrows in a Matrix
NEW: TikZ book now 40% off at Amazon.com for a short time.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p
Diagonal Arrows in a Matrix
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
Creating a Minimal Example: http://www.dickimaw-books.com/latex/minexample/
- Stefan Kottwitz
- Site Admin
- Posts: 10335
- Joined: Mon Mar 10, 2008 9:44 pm
Diagonal Arrows in a Matrix
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