Math & ScienceLine around the diagonal of a matrix

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
kapowza
Posts: 19
Joined: Fri Jan 30, 2009 3:32 pm

Line around the diagonal of a matrix

Post by kapowza »

I have a matrix

Code: Select all

$\begin{pmatrix}
a & b & c \\
d & e & f \\
g & h & i
\end{pmatrix}$
and I'd like to be able to draw a loop around the diagonal a-e-i. I know that I've seen something similar using tikz matrix in the past, but I can't figure it out now. Any ideas? Also, what if I wanted to draw a basic line through the diagonal instead of around it?
Last edited by kapowza on Sat Nov 28, 2009 5:42 pm, edited 1 time in total.

Recommended reading 2024:

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

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

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Line around the diagonal of a matrix

Post by localghost »

kapowza wrote:[…] I know that I've seen something similar using tikz matrix in the past, but I can't figure it out now. Any ideas? Also, what if I wanted to draw a basic line through the diagonal instead of around it?
If so, take a look at the pgf/tikZ manual or at some examples [1]. Otherwise the »Math mode« document may help.

[1] TikZ examples feature: Matrices


Best regards
Thorsten¹
Last edited by localghost on Sat Nov 28, 2009 5:56 pm, edited 1 time in total.
kapowza
Posts: 19
Joined: Fri Jan 30, 2009 3:32 pm

Line around the diagonal of a matrix

Post by kapowza »

If anyone's having the same issue that I was, I found a partial solution on page 109 of the "Math mode" document using the cline command - it shows how to make a box around a row or column. I'm still unsure how to get a box around the diagonal of a matrix, but if I make any progress, I'll post here.
Post Reply